On Wed, May 04, 2005 at 09:08:19PM +0900, Ralf Mler wrote: > Hi, > > i simply want so change an existing file [ ... ] > irb(main):012:0> file = File.open('test'); file.each do |line| line.gsub!(/\d+/,'###') end > AFAIK line is a String so changing it won't automatically change the file. There's a reason, too: Most operating systems do not support mixing reading and writing lines to the same file, since most OS's do not handle lines as distinctive records - i.e: changing the length of one line will generally mean changing all the content from that point till the end of the file, which is obviously very inefficient. Generally, the best you can do is open a new file for writing, write each line to the new file after changing it, and then rename/move the new file name to the old filename. Joost.