From: Jeremy Woertink Date: 2007-11-06T10:03:05+09:00 Subject: Re: Line ending problem. Cong Chan wrote: > Hi > > I am writing a ruby script to insert some content into the beginning of > some files. > > Thanks So you want to add stuff to the beginning of a file? Well, as far as I know, you can't just add stuff to the beginning, you have to create a new file, add your stuff, then append the old stuff at the end of the new file. new_file = File.new("your_new_file.txt", "w+") new_file.write("I'm at the beginning\n") IO.readlines("your_old_file.txt").each do |line| new_file.write(line) end new_file.close ~Jeremy -- Posted via http://www.ruby-forum.com/.