main reads and writes stdin and stdout