Ruby: Length of a line of a file in bytes?
I'm writing this little HelloWorld as a followup to [this][1] and the numbers do not add up

    format = "U*" # what should I put here?
    filename = "testThis.txt"
    total_bytes = 0
    file = File.new(filename, "r")
    while (line = file.gets)
      total_bytes += line.unpack(format).length
    end
    puts "original size #{File.size(filename)}"
    puts "Total bytes #{total_bytes}"

The result is not the same as the file size. I think I just nee to know what format I need to plug in... or maybe I've missed the point entirely. **How can I measure the file size line by line?**


  [1]: http://stackoverflow.com/questions/625733
Ruby: Length of a line of a file in bytes?
===

I'm writing this little HelloWorld as a followup to [this][1] and the numbers do not add up

    format = "U*" # what should I put here?
    filename = "testThis.txt"
    total_bytes = 0
    file = File.new(filename, "r")
    while (line = file.gets)
      total_bytes += line.unpack(format).length
    end
    puts "original size #{File.size(filename)}"
    puts "Total bytes #{total_bytes}"

The result is not the same as the file size. I think I just nee to know what format I need to plug in... or maybe I've missed the point entirely. **How can I measure the file size line by line?**


  [1]: http://stackoverflow.com/questions/625733