title: Reading Multiple lines in stdin using subprocess
body: <p>I am trying to run a c++ program from python. My problem is that everytime i run:</p>
  
  <pre><code>subprocess.Popen(['sampleprog.exe'], stdin = iterate, stdout = myFile)
  </code></pre>
  
  <p>it only reads the first line in the file. Every time I enclose it with a while loop it ends up crushing because of the infinite loop. Is there any other way to read all the lines inside the <code>testcases.txt</code>?</p>
  
  <p>My Sample Code below:</p>
  
  <pre><code>someFile = open("testcases.txt","r")
  saveFile = open("store.txt", "r+")
  
  try:
      with someFile as iterate:
          while iterate is not False:
              subprocess.Popen(['sampleprog.exe'],stdin = iterate,stdout = saveFile)
  
  except EOFError:
      someFile.close()
      saveFile.close()
      sys.exit()
  </code></pre>