Fixed segfault when reading from stdin to stdout