Change while loop to each_line.