prettier fix: rewrite while() loop into do .. while()

Avoids using the comma operator and is prettier!