How much is it off by? Are you saving the HTTP headers in the file? Are you writing the file using binary variables? Let's see your code.