perl -pe "binmode STDOUT;chomp;$_ = pack(q/B*/,$_);" infile >outfile