You're reading the file in text mode and writing it in binary mode.

This will fail on Python 3.  On Python 2 on Windows it will convert \r\n newlines to \n newlines.

I suggest dropping the 'b'.