F# version

fsc minimal.fs
minimal.exe 1 < input > myoutput
fc myoutput output

Input file needs an additional CRLF at the end. (DOS and weird EOF)