diff --git a/lib/Command/Index.php b/lib/Command/Index.php
index 63c1aac0..643c2bbb 100644
--- a/lib/Command/Index.php
+++ b/lib/Command/Index.php
@@ -216,10 +216,10 @@ class Index extends Command
if ($group = $this->groupManager->get($gid)) {
foreach ($group->getUsers() as $user) {
$closure($user);
- }
- } else {
- $this->output->writeln("Group {$gid} not found");
- }
+ }
+ } else {
+ $this->output->writeln("Group {$gid} not found");
+ }
} else {
$this->userManager->callForSeenUsers(static fn (IUser $user) => $closure($user));
}