How to prevent that CR and LF are changed when writing bytes to file? January 18, 2024 by Tarik If you want to write bytes then you should open the file in binary mode. f = open('/tmp/output', 'wb')