From: Chris Conley Date: 2008-06-19T07:52:05+09:00 Subject: Add new text to files Hello, I'm trying to insert new text into the middle of a file with the following: file = File.open("file.rb", "r+") file.each { |line| if line.match(/line text/) file.puts("hello") end } This works fine except that it overwrites the existing 5 characters to replace with "hello". Is there a way to insert a new line with new text without overwriting any existing data? Thanks! Chris