From: Lars Zeb Date: 2008-01-30T06:59:58+09:00 Subject: Re: newbie file write problem If I change to: f = File.new("d:\downloads\\text.txt", "w") File.open("D:\downloads\\SIC-small.txt").each { |line| s = SicCode.new(line.chomp).get_sql f.puts s } f.puts "This is a string" f.close Each input line is written as nil to the output file. And I do see the output I expect on the console. If I change the script to: File.open("D:\downloads\\SIC-small.txt").each { |line| s = SicCode.new(line).get_sql puts s } I see the expected output to the console as well. If it matters, here is the output for two lines: IF EXISTS (SELECT * FROM Sic WHERE Code = '3291') BEGIN UPDATE Sic SET Descr = 'ABRASIVE PRODUCTS' WHERE Code = '3291' END ELSE BEGIN INSERT INTO Sic SELECT '3291', 'ABRASIVE PRODUCTS', getdate() END nil IF EXISTS (SELECT * FROM Sic WHERE Code = '6321') BEGIN UPDATE Sic SET Descr = 'ACCIDENT AND HEALTH INSURANCE' WHERE Code = '6321' END ELSE BEGIN INSERT INTO Sic SELECT '6321', 'ACCIDENT AND HEALTH INSURANCE', getdate() END nil