From: Jeremy McAnally Date: 2006-11-01T23:04:01+09:00 Subject: Re: File I/O Hello, That works, or, even more Rubytastic: open("file.txt", "w") do |fd| fd.puts data end Using the block automatically closes the file. :) --Jeremy On 11/1/06, Peter Szinek wrote: > name pipe wrote: > > Hello, > > > > I have some text to be written to a file. > > After receiving data from webrick server I modify it lil bit and then > > write it to a file. > > > > fd = File.open("file.txt", "w") > You can use > > open("file.txt", "w") > > as well. > > > fd.puts "#{data}" > Why not just > > fd.puts data > > as for the empty file problem, maybe try to close fd: > > fd.close > > Peter > http://www.rubyrailways.com > > >