On Fri, Jul 24, 2009 at 12:20:36PM +0900, Mike Kasick wrote: > I'm looking for a non-destructive file advance operation, if that makes > sense. Two things: - Turns out Ruby 1.9's ARGF.eof? behavior was a bug, now fixed in svn trunk. A workaround is to call "ARGF.file" (or another ARGF accessor) before the while loop. - ARGF.skip is the non-destructive file advance operation that I was looking for. ARGF.close works too, but can also close $stdin which may not be preferred. Problem is that neither currently works when followed by ARGF.eof?. I submitted a patch to fix that to the issue tracker. Unfortunately this means that the behavior of ARGF with regard to close/eof/skip changes somewhat between patchlevels on Ruby 1.8.7 & 1.9.1. To answer my original question (and for the benefit of anyone else looking to do something similar), the following code includes the appropriate workarounds to work on, I believe, all 1.8/1.9 versions: # Print (or whatever) every line from all files listed in ARGV or $stdin. loop do current = ARGF.file while !ARGF.eof? puts ARGF.readline # Or whatever. end ARGF.skip.file == current and break end