> What exactly are "header lines" in your case? Without knowing the > format and your parsing / processing requirements it's difficult to > come up with suggestions. A header line starts with ">" First Entry, first file: >1_4_138_F5-P2 234234234234234 First Entry, second file: >1_4_138_F3 234234234234234 I have two large files(several gigs) that I need to read with a bunch of "entries" as the above shown. I need to match the header lines, in this case i need to make sure "1_4_138_" is the same in both entries and if it is, write those entries with matching headers to new seperate files. I'm not done writing the script yet(didn't test it either), but this is what I have: while !f3_file.eof? while !f5_file.eof? f5_ln = f5_file.readline if f5_ln =~ /(\d*_\d*_\d*_)/ f5_ln += f5_file.readline end f5_out.puts(f5_ln) end f3_ln = f3_file.readline if f3_ln =~ /(\d*_\d*_\d*_)/ f3_ln += f3_file.readline end end -- Posted via http://www.ruby-forum.com/.