2007/11/23, Lee Jarvis <jarvo88 / gmail.com>: > > This is more efficient - no need to load the whole file into mem to > > find a single line: > > > > File.foreach "file.txt" do |line| > > if /rx/ =~ line > > puts "found it" > > break > > end > > end > > > > Cheers > > > > robert > > Ahh, good point, touche my good man. While we're at it: there is another solution - probably a bit more elegant: require 'enumerator' File.to_enum(:foreach,"file.txt").grep(/rx/) {|li| puts li; break} :-) Kind regards robert -- use.inject do |as, often| as.you_can - without end