From: fox foxmaster Date: 2012-04-16T15:27:34+09:00 Subject: insert text after line "whatever" Hi all, I have a problem that I am struggling with. Problem I have is that I want to insert text in a text file after a specific line. My thought was to copy the original file line by line and when I got to a specific line it would insert the text that I wanted, but I did not manage to do this so I went another way, like this File.open('test.bak', 'r+') do |file| file.each do |line| if line =~ /\<\/DHCPServer>/ #trigger file.seek(-line.size, IO::SEEK_CUR) file.puts ("Hello") #text to input end end end But when I use this, first it manipulates the original file and it deletes some of the letter of the trigger "" So can someone guide me to the right path? Regards Fox -- Posted via http://www.ruby-forum.com/.