title: File written by json.dump() not readable by json.load()
body: <p>I'm creating a setup script for my Python project. The script reads build configurations from a json file like so:</p>
  
  <pre><code>with open('setup.conf','r') as configfile:
      config = json.load(configfile)
  </code></pre>
  
  <p>which works perfectly. Later in the script, I constrain myself to a part of that object and write this part to another file:</p>
  
  <pre><code>config = config[arg]
  [...]
  with open('kivy/app.conf','w') as appconfig:
      json.dump(config,appconfig)
  </code></pre>
  
  <p>which at least does not generate any errors.
  Upon startup of my main app, I then want to read the file I just created:</p>
  
  <pre><code>path = os.path.dirname(os.path.abspath(__file__))
  with open(path + '/app.conf','r') as configfile:
      config = json.load(configfile)
  </code></pre>
  
  <p>This, however, fails with a </p>
  
  <pre><code>simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
  </code></pre>
  
  <p>indicating that the json written by json.dump() itself is invalid from the very first character onwards. The data itself is as unsuspicious as it can get, all plain ASCII characters, no weird line endings etc.:</p>
  
  <pre><code>{"deploy_server": false, "run_server": true, "server": "127.0.0.1", "run_app": true, "deploy_iOS": false, "user": "", "debug": true, "path": "", "deploy_android": false, "port": "8000"}
  </code></pre>
  
  <p>I don't have the slightest idea where this could be coming from. Any help is greatly appreciated!</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I discovered that the very same code above works in a live interpreter session. I conclude from this that there must be something strange going on in the code surrounding this, but I'm at loss here as well: There probably is an obvious elephant in the room, but I can't see it. The surrounding code looks like this:</p>
  
  <pre><code>from kivy.app import App
  from kivy.uix.gridlayout import GridLayout
  from kivy.uix.label import Label
  from kivy.uix.textinput import TextInput
  from foodcalendar import CalendarWidget
  from kivy.resources import resource_add_path
  import os
  import requests
  import json
  
  
  [...]
  
  class MyApp(App):
      def __init__(self):
          super(MyApp,self).__init__()
          path = os.path.dirname(os.path.abspath(__file__))
          print path
          with open(path + '/app.conf','r') as configfile:
              for r in configfile:
                  print r
                  config = json.loads(r)
          self.server = config["server"]
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>It turns out that the error I'm facing is somehow related to the <code>requests</code> module: If I comment out <code>import requests</code>, everything works as expected, but I'm clueless as to why this happens, since the docs of the <code>json</code> and <code>requests</code> modules remain silent about any incompatibilities...</p>
  
  <p><strong>UPDATE 3</strong></p>
  
  <p>This seems to be a machine dependent issue. I ran my code on another machine, and there it ran flawlessly. Python is version 2.7.12, OS is Ubuntu 16.04 x86_64, kernel version is 4.4.0.38-generic on both machines...</p>