title: BufferedWriter and map function: empty files
body: <p>I am trying to write a huge output file the quickest possible on two different files.
  I have created my lists list1 and list2, and I am now trying to write those in a respective file.</p>
  <p>I started to increase the buffer size by doing so:</p>
  <pre><code>rand_file = io.FileIO(&quot;test1.txt&quot;, 'w')
      
  writer = io.BufferedWriter(rand_file,buffer_size=500000000)
          
  for x in mylist1:
  
      writer.write(x.encode())
  
  writer.flush()
  
  rand_file = io.FileIO(&quot;test2.txt&quot;, 'w')
      
  writer = io.BufferedWriter(rand_file,buffer_size=500000000)
  
  for x in mylist2:
  
      writer.write(x.encode())
  
  writer.flush()
  </code></pre>
  <p>but now I wanted to change those &quot;for loops&quot; with list comprehension but I cannot make it work.</p>
  <p>if I do the following:</p>
  <pre><code>writer.write(x for x in mylist1)
  </code></pre>
  <p>I do have the following error <em><strong>&quot;TypeError: a bytes-like object is required, not 'generator'&quot;</strong></em>. Note I also tried <code>writer.write(x.encode() for x in mylist1)</code>, with the same result.</p>
  <p>I then wanted to use the map function like so:</p>
  <pre><code>map(writer.write, mylist1)
  </code></pre>
  <p>This time, no error are raised but my output files are empty.</p>
  <p>What am I doing wrong here ?</p>