From: zdennis Date: 2005-12-02T02:09:41+09:00 Subject: Re: What is the best way to edit a file to eliminate a line Ok, slightly more elegant... class File def self.modify filename if block_given? data = IO.read filename begin file = File.open filename, 'w' yield file, data rescue Exception => ex file.open( filename, 'w' ){|file| file.write data } ensure file.close unless file.closed? end end end end File.modify( 'stuff.txt' ) do |writable_file, original_file_contents| writable_file.write original_file_contents.gsub /foo(\n|$)/, '' end Hope this works better... Zach