Fixing bug in while statement.