Not waiting for the child process to exit before reading from the output stream, it hangs the process