From: "phil.swenson@..." Date: 2007-04-04T02:00:09+09:00 Subject: Re: search a file and replace text well I *THOUGHT* I knew how to do it, here's my first crack at it: file_name = base_config_path + '/Caching/tangosol- coherence.xml' File.open(file_name, File::RDWR).each{ |line| if line.gsub!(/30890/, port.to_s) puts "tangosol port overridden with %d" % port break end } The gsub doesn't modify the line, guess it just modifies the string. How do I actually modify the file itself? btw, I did look at rexml but it looked like overkill for this. I'll take another look though.