Working of while loop