Fixes to while loop

Forgot to increment f, fixed formatting of printf statements.