Editing while loop code