From: Ben Martinek Date: 2009-08-09T12:00:23+09:00 Subject: Basic iteration through text Howdy! So I am trying to parse a bit of an ugly text file to a new file, and hence read each line of the old file, check the line for some conditions and then execute some other stuff, and then write out some results to a new file. Here is what I came up with: my_file = File.new("New_file.txt", "w+") File.foreach("LOG02.txt") do |line| if line =~/^\$GPRMC/. my_file.puts line else print "I did not read this line: #{line}" end end I have a feeling that I am missing something stupid but not quite sure what it is. Good karma for a solution :-) -- Posted via http://www.ruby-forum.com/.