From: "Cyril J." Date: 2011-09-14T10:26:18+09:00 Subject: Re: Large file reading > Do you have guaranteed ordering for the header lines in each file? The headers should be in the same order in both files. Some headers are going to be missing in the second file however, which is why I need to do the check. If a header doesn't match one from the first file, then those two headers don't get written out to the file. Here is an update from my original code: cs_files = Dir.glob("Desktop/scripts/*.csfasta") f3_file = File.open(cs_files[0]) f5_file = File.open(cs_files[1]) f3_out = File.new("/Users/cjose/Desktop/f3.csfasta", "w") f5_out = File.new("/Users/cjose/Desktop/f5.csfasta", "w") while !f3_file.eof? && while !f5_file.eof? f3_ln = f3_file.readline.chomp f5_ln = f5_file.readline.chomp if f3_ln =~ /^>\d*_\d*_\d*_F3$/ f3_headers = f3_ln.gsub(/F3/, "") end if f5_ln =~ /^>\d*_\d*_\d*_F5-P2$/ f5_headers = f5_ln.gsub(/F5-P2/, "") if f3_headers == f5_headers puts f3_headers puts f5_headers puts "worked" else puts f3_headers puts f5_headers puts "nope" end end end # end while end # end while f3_file.close f5_file.close -- Posted via http://www.ruby-forum.com/.