Make OCC show who has enabled 2FA


I’m trying to figure out how to get OCC to list 2FA state on all users.
First I ran the command: sudo -u www-data php /var/www/nextcloud/occ twofactorauth:state
Then I figured this was too time consuming, so I took all UID into a text file, and saved it as users.txt in tmp folder, and tried to use this file as source for $user. Like this:

while IFS= read -r user; do
sudo -u www-data /var/www/nextcloud/occ twofactorauth:state $user
done < "/tmp/users.txt"

I double checked the UIDs with this command, and it turns out fine:

while read line; do
echo $line
done < /tmp/users.txt

I thought this would work, but the only output I get is
Invalid UID

Has anyone got a better suggestion?