Fixed read from STDIN and write to file.