perl -pe "BEGIN{binmode *STDOUT}" file.txt > file2.txt