title: Python: How to write to file and download it?
body: <p>I a have flask based web service where I trying to download the results to a file to user's desktop (via https).</p>
  
  <p>I tried :</p>
  
  <pre><code>def write_results_to_file(results):
      with open('output', 'w') as f:
       f.write('\t'.join(results[1:]) + '\n')
  </code></pre>
  
  <p>this method gets activated when I click export button in the ui.</p>
  
  <p>But I am getting :</p>
  
  <pre><code>&lt;type 'exceptions.IOError'&gt;: [Errno 13] Permission denied: 'output'
        args = (13, 'Permission denied')
        errno = 13
        filename = 'output'
        message = ''
        strerror = 'Permission denied' 
  </code></pre>
  
  <p>Can some one tell me what I am doing wrong here ?</p>