From: nlper@... (Tyler) Date: 2001-07-12T13:10:35+09:00 Subject: [ruby-talk:17694] Funky file.each_byte Howdy! I was filtering some files and ran into an anomaly. I'm running Ruby 1.6.4 on an old Windows machine. Everything was fine when I was manipulating bytes with getc/putc, but that seemed too C-ish, so I tried a tweak to a Ruby idiom. Imagine my surprise and delight to discover that a file with some bytes deleted was larger than the original file! Ditto for reading. count = 0 f = File.new( ARGV[0], "r") f.each_byte do count += 1 end f.close printf( "%s had %d bytes via .each_byte,\n", ARGV[0], count) printf( "while file.stat.size reports %d bytes.\n", File.stat(ARGV[0]).size) generates the following results: H:\ruby >ruby fsize.rb 1MEG.1 1MEG.1 had 1048553 bytes via .each_byte, while file.stat.size reports 1048576 bytes. Any ideas? Is this a Windows-specific oddity or showing up elsewhere? TIA, Tyler