I agree that you need to open the file in binary mode.
The two problems you've found so far are easily explained.
0x1A is the EOF character. When reading a file in ascii mode, this character is interpreted to mean end of file, and the code behaves accordingly.
0x0d and 0x0a are both end of line characters. Some platforms need both together to indicate end of line. If you are on one of these platforms, you will see the behavior you described.
There may be other similar translations which occur with other characters. I vaguely remember that the NUL character (0x00) is a problem on some platforms.
The purpose of these translations are to simplify writing a text file. Opening the file in binary mode disables all of these behaviors.