Extract declared names from while loop