From: James Gray Date: 2008-11-16T14:13:31+09:00 Subject: Re: IO#lineno= doesn't work the way I expected On Nov 15, 2008, at 7:38 PM, Chad Perrin wrote: > On Sun, Nov 16, 2008 at 09:51:16AM +0900, Jens Wille wrote: >> > >> not sure what tim was suggesting, but this will work: >> >> in_fh = File.open(infile, 'r') >> out_fh = File.open(outfile, 'w') >> >> # ignore first line >> in_fh.gets >> >> in_fh.each_line do |l| >> out_fh << l >> end >> >> ok, it's not pretty, but not *that* ugly either, is it? ;-) > > Actually, that looks pretty good, all things considered. I didn't > realize the IO#gets would increment the line number of the file so the > each_line iterator would start on the second line. If that's how it > works, I'm home free. Thank you for your help. > > I'll go test this now to make sure it works. It works fine and, to be clear, it has nothing to do with line numbers. gets() reads forward to a newline character, advancing the file pointer (represented by tell()/pos()) normally. each() works the same way, beginning at the current file pointer location. I think this is pretty standard I/O streaming logic in any language. James Edward Gray II