From: Adam Shelly Date: 2007-12-08T05:14:33+09:00 Subject: Re: Question about iterators and reading a file On 12/7/07, Jon Handler wrote: > Hi All, > And I have this piece of loop: > > f = open(File, 'r').each do |l| > strIn = l.chomp > > # Now what!?!! > > end > > I need to advance to the next line of the file within the loop but I > can't for the life of me figure out how to do that. This can't be hard, > but it's defeated me so far! > That's the cool thing about 'each' - you don't have to do anything else. The code inside the do-end block will be called for each line, with l set to that line. Try adding 'puts strln' in place of "Now what". That will print the whole file. Then replace the puts with whatever processing you want to do on each line. -Adam