title: Flush and fsync not work in a tempfile
body: <p>I'm trying to create a file. In this file I put all the files that I need to process in a script and I pass the file as a parameter. My problem is that sometimes the list is not long enough to fill the buffer and nothing is written in disk. I tried to flush and fsync the tempfile but nothing happens. The Script is a third party script so I can't change the way the parameters are passed.</p>
  
  <pre><code>with tempfile.NamedTemporaryFile(bufsize=0) as list_file:
      list_file.write("\n".join(file_list) + "\n")
      list_file.flush()
      os.fsync(list_file)
  
      command = "python " + os.path.join(SCRIPT_PATH, SCRIPT_NAME) + " --thread --thread_file "
      ppss_command = [SCRIPT_PATH + "/ppss", "-f", list_file.name, "-c", command]
      p = subprocess.Popen(ppss_command)
      out,err = p.communicate()
  </code></pre>
  
  <p>Final Solution Code(jterrace Answer): </p>
  
  <pre><code>with tempfile.NamedTemporaryFile(delete=False) as list_file:
       list_file.write("\n".join(file_list) + "\n")
       list_file.close()
       command = "python " + os.path.join(SCRIPT_PATH, SCRIPT_NAME) + " --thread --thread_file "
       ppss_command = [SCRIPT_PATH + "/ppss", "-f", list_file.name, "-c", command]
       p = subprocess.Popen(ppss_command)
       out, err = p.communicate()
       list_file.delete = True
  </code></pre>