From: Robert Klemme Date: 2009-08-17T15:50:22+09:00 Subject: Re: while !file.eof? 2009/8/17 botp : > On Mon, Aug 17, 2009 at 10:03 AM, Derek > Smith wrote: >> How can I use a while loop in such as way where I want to process the >> file until EOF? > > on your case, you do not need the EOF sig. Pls read on ruby's > iterators and File. > >>.... >> File.open(mailog, 'r+').each { |line| >>        while !mailog.eof? >>            if line =~ /^#{last_record}/o >>                p line >>            end >>        end >> } > > > try eg, > > File.open( "maillog" ).each do |line| >  p line if line =~ /^#{last_record}/ > end You're not closing the file handle properly. :-) Better: File.foreach "maillog" do |line| p line if /^#{last_record}/o =~ line end Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/