reading file from particular line containing some keyword in ruby
I am new to programming please help me.
I need to read a file from particular line based on the time and write the same into another file. But its skipping the first line while writing into the other file.
    `timeStr="2011-08-01 02:24"
     File.open(path+ "\\logs\\messages.log", "r") do |f| 
     # Skip the garbage before pattern: 
     while f.gets !~ (/#{timeStr}/) do; end                   
     # Read your data: 
     while l = f.readlines
     File.open(path+ "\\logs\\messages1.log","a") do |file1|
     file1.puts(l)
     end
     end 
     end`

When am running the above script the first line matching timeStr is skipped and from the second line the file is written in to the messages1. when I open messages1.log file the first line containing the matching string will not be present. Any idea how to include the first line also while writing to the messages1.log file. 
reading file from particular line containing some keyword in ruby
===

I am new to programming please help me.
I need to read a file from particular line based on the time and write the same into another file. But its skipping the first line while writing into the other file.
    `timeStr="2011-08-01 02:24"
     File.open(path+ "\\logs\\messages.log", "r") do |f| 
     # Skip the garbage before pattern: 
     while f.gets !~ (/#{timeStr}/) do; end                   
     # Read your data: 
     while l = f.readlines
     File.open(path+ "\\logs\\messages1.log","a") do |file1|
     file1.puts(l)
     end
     end 
     end`

When am running the above script the first line matching timeStr is skipped and from the second line the file is written in to the messages1. when I open messages1.log file the first line containing the matching string will not be present. Any idea how to include the first line also while writing to the messages1.log file. 