- properly write and close stdin on Popen