Jacob Fugal escribióº > On 1/19/06, Diego Algorta Casamayou <ruby / dac.e4ward.com> wrote: >> Change >> >>> File.open("testfile", "r") do |file| >> to >> >>> File.open("testfile", "w") do |file| > > Well you need more than that. For one thing the file.gets will fail if > file was opened in write mode. Also the puts is going to STDOUT, not > the file. You probably want something like this: > > #!/usr/bin/ruby > File.open("testfile", "w") do |file| > while line = gets > file.puts line > end > end > > This will get input from STDIN and write it out to test file. Program > terminates on EOF marker (CTRL-D when run interactively). That's right. I focused my reply on on the open method, but missed the full example. Diego