Updated the while loop

if-statement on the placed wrong