title: EOF error when reading dict from file
body: <p>I have a .txt file that contains a dict in the following format:</p>
  
  <pre><code>{
   "key1": "value1",
   "key2": "value2",
  }
  </code></pre>
  
  <p>I'm trying to read this into a variable so I can use it.  I can do so with something like:</p>
  
  <pre><code>    f = open('my_dict.txt', 'r')
      my_dict = eval(f.read())
  </code></pre>
  
  <p>But if I try to use the below, Python complains about an unexpected EOF after the first "{".</p>
  
  <pre><code>dict_from_file = []
  with open('my_dict.txt', 'r') as inf:
          for line in inf:
              dict_from_file.append(eval(line))
  print(dict_from_file)
  
  
       { 
       ^
  SyntaxError: unexpected EOF while parsing
  </code></pre>
  
  <p>I'm sure it just has to do with everything formatted line by line in the file.  I guess I could reformat the file so that newlines are replaced with ",", but I like having the readability of every key:value pair on a line.  I'd like to be able to use <code>with</code>.  How can I go about doing that?</p>