From: Shane Emmons Date: 2008-11-22T07:33:07+09:00 Subject: Re: append new line to textfile ------=_Part_37896_10567831.1227307028383 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Fri, Nov 21, 2008 at 5:23 PM, Siep Korteling wrote: > Shane Emmons wrote: > > On Fri, Nov 21, 2008 at 4:41 PM, Mmcolli00 Mom > > wrote: > > > >> 'completed' starttime 05:00 endtime 23:00 > >> > > File.open('logfile.txt', 'w+') do |f1| f1.write(logline) > > end > This will destroy the content of logfile.txt. For appending to a file > instead of overwriting it, use "a" > > 3.times do |n| > logline = "logline #{n}" > File.open('D:/temp/logfile1.txt', 'w+') do |f1| > f1.puts(logline) > end > File.open('D:/temp/logfile2.txt', 'a') do |f1| > f1.puts(logline) > end > end > > hth, > > Siep > -- > Posted via http://www.ruby-forum.com/. > > whoops, sorry about that. -- Shane Emmons ------=_Part_37896_10567831.1227307028383--