title: extra characters "??" get added to the file name when i try creating a text file in python
body: <p>I am trying to create a text file with unique names depending upon the <code>id</code>value 
  My code is</p>
  
  <pre><code>with open('USER_LIST', "r") as file:
      for core_id in file:
          filename = "%s.txt" %core_id
          with open(filename, "w") as file:
              subprocess.Popen("query where coreid=%s"%core_id, stdout=file , shell=True)
  </code></pre>
  
  <p>The file <code>USER_LIST</code> is a text file that contains a list of user id's. I want to run a command for individual id and store the result in a text file</p>
  
  <p>Here when the text file gets created it gets created as <code>id??.txt</code> for e.g. <code>abc123??.txt</code>
  I am not sure from where are these <code>??</code> getting added in my file names.
  How to fix this?</p>