You terminated the process, and never flushed/closed the input to it, so all the data was stuck in buffers and discarded when the process was forcibly killed. You can use communicate to combine passing input, closing stdin, then waiting for the process to complete:
import subprocess
with open('outfile.out', 'w') as out:
pp=subprocess.Popen(['/bin/cat'],stdin=subprocess.PIPE,stdout=out)
pp.communicate('Line I want into out file\n')
In this case (only one of the three standard handles is a pipe), you could also do this safely:
import subprocess
with open('outfile.out', 'w') as out:
pp=subprocess.Popen(['/bin/cat'],stdin=subprocess.PIPE,stdout=out)
pp.stdin.write('Line I want into out file\n')
pp.stdin.close()
pp.wait() # Optionally with a timeout, calling terminate if it doesn't join quickly
That should only be done if you are only using a single standard handle as PIPE; if more than one is PIPE, there is a risk of deadlock (child is writing to stdout, waiting for you to read to clear the buffer, you are writing to stdin, waiting for child to read to clear the buffer) that communicate resolves by using threads or the select module, and you'd have to mimic that design to avoid deadlock.