From: "JeremyWoertink@..." Date: 2007-11-15T08:57:26+09:00 Subject: Re: Recursion help. Done! Works great, but I am always interested in seeing how it can be better. Less code, cleaner, faster sort of thing. Here it is, if anyone has any ideas on how I can make it better, please do tell. puts "Enter file name" filename = gets.chomp puts "Enter carton size" carton_size = gets.chomp puts "Enter header description" description = gets.chomp out_file = File.new("C:/test/#{description}.xls", "w+") out_file.write("#{description}\n") out_file.write("Carton number \t Carton quantity \t Card number \n") file_size = IO.readlines(filename).size total_cartons = (file_size.to_f / carton_size.to_f).ceil i = 0 sequence = 1 in_file = File.open(filename) until in_file.eof? (i..(carton_size.to_i - 1)).each do |number| if in_file.eof? in_file.close out_file.close puts "Done!" exit end record = in_file.readline out_file.write("#{sequence}\t#{total_cartons}\t#{record[7, 19]} \n") end sequence += 1 end