From: Jacob Fugal Date: 2006-01-20T01:10:02+09:00 Subject: Re: Unable to write to file... (example from "pickaxe book", second edition, p128) On 1/19/06, Diego Algorta Casamayou 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). Jacob Fugal