On 05/13/2010 02:40 AM, Vandana wrote: > On May 12, 4:18 pm, Thomas Volkmar Worm <t... / s4r.de> wrote: >> File.open("myfile", "r") do |f| >> >> # Skip the garbage before pattern: >> while f.gets !~ /pattern/ do; end >> >> # Read your data: >> while l = f.gets >> puts l >> end >> >> end There's also the flip flop operator: File.foreach "myfile" do |line| if /pattern/ =~ line .. false puts line end end The trick I am using is that the FF operator starts to return true if the first expression returns true and stays true until the last expression returns true - in this case never since you want to read until the end of the file. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/