Why keeping a var and using a while? why not for(...)?