From: Mike McKinney Date: 2007-12-14T00:20:26+09:00 Subject: Re: read in file ------=_Part_42436_22530425.1197559228640 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline another way... File.open('out.txt', 'w') do |out| File.open('test.txt', 'r').each do |line| out.puts line if (line.size > 4) end end Here are some ways to pull each line from a file in other languages: http://blog.huikau.com/2007/11/25/simple-file-io-in-different-dynamic-languages/ M On Dec 13, 2007 9:54 AM, Sebastian Hungerecker wrote: > Chris Daves wrote: > > f = File.open(references, 'r') > > file_data = f.read > > f.close > > That can be written as > file_data=File.read("references") > It's generally better not to use File in a way that you have to manually > close > the file. > > > > but i want to take this file data and interpret each line of data and > > the put each line into a new file line by line. > > File.open(outfile, "w") do |of| > File.foreach(infile) do |line| > do_something_with line > of.puts line > end > end > > > HTH, > Sebastian > -- > NP: In Flames - Everdying > Jabber: sepp2k@jabber.org > ICQ: 205544826 > > ------=_Part_42436_22530425.1197559228640--