Output now writes properly, but child process needs to be killed