fixing transition from if statement to the for loop in read_lines