Better handling of stdin and stdout.