File size differences after copying a file to a server vía FTP

Do you need to open the locfile in binary using rb?

f = open (locfile, "rb")

Well if you go under the properties of your file in Windows or a *nix environment, you will notice two sizes. One is the sector size, and one is the actual size. The sector size is the number of sectors in bytes that are used up on your hard disk. That is because two files cannot be in the same sector with most modern file systems, so if your file fills up half of the sector the whole sector is marked as filled.

So you might be comparing the sector file size to the actual file size on the FTP server or vice versa.