Tidy up while loop to do...while.