From: Ronald Fischer Date: 2007-08-24T20:39:42+09:00 Subject: Re: How to append some data at the beginning of a file > Thanks Ronald for your comments. I am wondering may be ruby > got some way > around it. It could, but I think it just happens too rare that someone wants to do this. In more than 2 decades of programming, I had this need only two or three times, for example. > newfile = File.new("test1","w") > newfile.puts "This line should appear at the top of each file"; > > oldfile = File.open("test", "r+") > oldfile.each_line { |line| newfile.puts line} > oldfile.close(); or simply newfile.puts(File.read("test")) so you don't need the Ruby variable 'oldfile'. > newfile.close(); > > File.delete("test"); > File.rename("test1", "test"); -- Ronald Fischer Phone: +49-89-452133-162