From: Robert Klemme Date: 2004-07-22T18:12:01+09:00 Subject: Re: tempfile iterator? "tony summerfelt" schrieb im Newsbeitrag news:lr1uf0p3ul2p62sd8tob6onf04trsjnc23@4ax.com... > On Thu, 22 Jul 2004 05:00:54 +0900, you wrote: > > > >if @lg is a variable holding the filename then that should be > > >open(@lg, 'a') {|f| f.write tlf.read} > > >The code you wrote would be trying to append to a file called '@lg' > > yup. i figured that out when i applied some common sense... > > for some reason, with that line it the thread is hanging...i might > have to rethink the way i've done things :) Maybe you forgot to seek? Note also, taht "f.write tlf.read" will slurp the whole file into mem before writing it out again. This may or may not be a problem, depending on the size of your file. Taking this together you might want to do this: # reset file position of the open Tempfile tlf.seek 0 # copy in chunks open(@lg,'a') do |f| while ( data = tlf.read 1024 ) f.write data end end Regards robert