Modified the way piped output is read, in a way that should be cross-platform.