title: os.path.join throws error 'type of argument must be str or bytes not TextIOWrapper'
body: <p>I am trying to open and then read from a json-file (also later on do the same and dump some json data into the same file btw).</p>
  
  <p>I simply wanted to use a variable for the file name so my code for this looks like this:</p>
  
  <pre><code>layout_file = 'layouts2.json'
  try:
      filename = os.path.join(app.static_folder, layout_file)
      with open(filename) as layout_file:
          layouts = json.load(layout_file)
  except:
      print("could not load layouts from config file")
  </code></pre>
  
  <p>Before my code looked like this and worked fine:</p>
  
  <pre><code>try:
      filename = os.path.join(app.static_folder, 'layouts2.json')
      with open(filename) as layout_file:
          layouts = json.load(layout_file)
  except:
      print("could not load layouts from config file")
  </code></pre>
  
  <p>The error i get is <code>error 'type of argument must be str or bytes not TextIOWrapper'</code>. 
  I don't really get what to do now, even this should be solvable pretty fast I guess.
  Thanks in advance!</p>