Possible issues:
- Your program opens the binary file in the text mode, which damages the
'\r'
and'\n'
bytes - Your program incorrectly handles zero bytes, treating them as ends of strings (
'\0'
) and not as data of its own - Your program uses
char
(that is actuallysigned char
) for the bytes of data and correctly works only with non-negative values, which ASCII chars of English text are, but fails to work with arbitrary char/byte values, which may be negative - Your program has an overflow somewhere which shows up only on big files
- Your program has some other data-dependent bug