While loop not iterating correctly

Printable View