From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-06-25T02:51:01+09:00 Subject: Re: reading file text On Tue, 24 Jun 2003 13:30:06 +0000, Dan wrote: > I have a file which I want to extract specific lines and put them together > into a new string, for an example this is what the input file is How about this ? > ruby a.rb a.rb > cat results.txt file = ARGV[0] has the text result = File.open("results.txt", "w") right below it lines = IO.readlines(file) has the text while lines.size > 1 right below it a, b = lines.slice!(0, 2) has the text a.chop! right below it b.chop! has the text result.puts "#{a} has the text #{b} right below it" right below it end has the text result.close right below it > cat a.rb file = ARGV[0] result = File.open("results.txt", "w") lines = IO.readlines(file) while lines.size > 1 a, b = lines.slice!(0, 2) a.chop! b.chop! result.puts "#{a} has the text #{b} right below it" end result.close > -- Simon Strandgaard