From: 7stud -- Date: 2009-09-13T04:30:54+09:00 Subject: Re: Backtracking through a file 7stud -- wrote: > M. Q. wrote: >> IO.gets steps through a file one line at a time. > > As does IO.foreach. And IO.foreach's block terminates naturally when > the end of the file is reached: > > IO.foreach("data.txt") do |line| > puts line > end > ..and foreach closes the file for you automatically. -- Posted via http://www.ruby-forum.com/.