From: "lrlebron@..." Date: 2008-06-23T12:18:21+09:00 Subject: Re: changing a file inline on Windows You can use the rio library to simplify this require 'rio' rio(f) wrote: > Here is my current method for editing files: > > > >   filename = File.join('path', 'to', 'file') >   content = [] >   File.open(filename, 'r') do |file| >     content = file.readlines >   end > >   content.collect! do |line| >     line.gsub!(/six/, "half a dozen") >     line.chomp >   end > >   File.open(filename, 'w') do |file| >     file.write content.join($/) >   end > > > > This is expensive though, as it rewrites the entire file, even if only a > single word in the whole file is changed.  I'm wondering if there is a > better way to do this. > > James > -- > Posted viahttp://www.ruby-forum.com/.