From: "lrlebron@..." Date: 2008-06-23T20:23:11+09:00 Subject: Re: changing a file inline on Windows On Jun 21, 11:16 pm, James Dinkel 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/. There was a small error in my previous post. Here a more complete script require 'rio' ario = rio(filename) ario < ario.contents.gsub(/six/, "half a dozen")