IO.foreach instead of each_line