Ok. But I refer you to https://perldoc.perl.org/functions/binmode.html. In general, binmode should be called after open but before any I/O is done on the filehandle. Yes, there are some exceptions to this "rule". But I figure this "rule" is a good one.