title: Python requests data in file, line by line
body: <p>I try to get the output of this request (<a href="https://api.opendota.com/api/players/7841909" rel="nofollow noreferrer">https://api.opendota.com/api/players/7841909</a>) in a file, line by line.</p>
  
  <p>For some reason the output is stored in byte and not str, which I can change by str().</p>
  
  <p>I tried to use a regualar expression to just store the information between the {} and also tried the csv module, which lead to just store digits.</p>
  
  <p>What did I do wrong? The following version ignores the linebreak and the delimiters. :/</p>
  
  <pre><code>import requests
  import csv
  import re
  
  dotaId = "7841909" #somit als string gespeichert
  pfad = "https://api.opendota.com/api/players/" + dotaId + "/matches"
  
  req = requests.get(pfad)
  
  with open('%s.csv' % dotaId, 'w') as file:
      clean_line = re.findall(r'\{(.*?)\}', req.text)
      file.write(str(clean_line))
  </code></pre>