Add stdin=PIPE to calls to Popen where stdout=PIPE