title: Convert nested dictionary to a json with a principal key in each line
body: <p>I have a nested dictionary which I am trying to convert to a JSON file using json.dumps(). Using the following code:</p>
  
  <pre><code>import json
  
  dictionary={'Galicia':{'ACoruña':1,'Pontevedra':2,'Lugo':3,'Ourense':4},'Asturias':{'Oviedo':5},
              'Castilla':{'Leon':6,'Burgos':7,'Avila':8}}
  print(dictionary)
  
  with open ('prueba.txt','w') as outfile:
      json.dump(dictionary,outfile,ensure_ascii=False,indent=4)        
  
  </code></pre>
  
  <p>I get this:</p>
  
  <pre><code>{
      "Galicia": {
          "ACoruña": 1,
          "Pontevedra": 2,
          "Lugo": 3,
          "Ourense": 4
      },
      "Asturias": {
          "Oviedo": 5
      },
      "Castilla": {
          "Leon": 6,
          "Burgos": 7,
          "Avila": 8
      }
  }
  
  </code></pre>
  
  <p>But I would like to put in my JSON in a way that each principal key is on a new line to make it easier to read. I would like it to look like this :</p>
  
  <pre><code>
  {
  "Galicia": { "ACoruña": 1 , "Pontevedra": 2, "Lugo": 3, "Ourense": 4},
  "Asturias": { "Oviedo": 5},
  "Castilla": { "Leon": 6, "Burgos": 7, "Avila": 8}
  }
  
  </code></pre>
  
  <p>Any ideas?</p>