On Fri, Jul 24, 2009 at 11:42:00AM +0900, Heesob Park wrote: > You can use ARGF.each for both 1.8.x and 1.9.x. > > Try > $ ruby -e 'ARGF.each{|l|puts l}' /tmp/foo /tmp/bar Right, I understand that this works in this particular example. Perhaps a more indepth example helps illustrate the problem better. Presume I have a method, "parse", that parses data records from an IO stream. It looks something like this: def parse(io) first = io.readline ... # Code to validate first second = io.readline ... third = io.readline ... ParsedThing.new(first, second, third) end The idea is to call "parse ARGF" only when I know there's data left in the stream to be parsed. Otherwise if I get an EOFError its meaning is ambiguous--there could be an incomplete data record (i.e., could parse "first" and "second", but got an EOF while reading "third"), or there could be no more records in the file. ARGF.each isn't going to work since ARGF is being used as an external iterator by the parse method, and calling ARGF.gets/readline outside the parse method strips the first line of a record. I'm looking for a non-destructive file advance operation, if that makes sense.