Hi all,

I'm having trouble getting an open/write/close cycle to actually put the 
correct data in the file. Here's some code that illustrates the problem:

<snip>
x = "012345678\n"
10.times do
  len = 0
  begin
    len = File.stat( 'junk').size
  rescue
    len = 0
  end
  puts len.to_s
  f = File.open 'crapper', 'w'
  f.seek len
  f.write x
  f.close
end
</snip>

produces:

0
10
20
30
40
50
60
70
80
90

as output. However, the file 'junk' is filled with zeroes, except for 
the last 10 bytes, which are what you'd expect them to be:

<snip>
puma:~> od -h junk
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0000120 0000 0000 0000 0000 0000 3130 3332 3534
0000140 3736 0a38
0000144
puma:~>
</snip>

Anyone know what I'm doing wrong? I tried using sysseek and syswrite, 
but I got the same results. Is Ruby's internal buffering screwing me up 
here somehow? TIA.

--
Toby DiPasquale

-- 
Posted via http://www.ruby-forum.com/.