The test is being done outside of the loop. It needs to be inside the loop.