title: How to save every output data in loop by python dictionary
body: <p>Today i found problem in my python dict. I need to collect  all output data from loop and write it in json file. Process of writing works well, but, as result, inside json file only one, last output. How i should fix part of my code with dictionary? Here is code:</p>
  
  <pre><code>def classify(sess, label_list, softmax_output, coder, images, image_file):
  
  print('Running file %s' % image_file)
  image_batch = make_batch(image_file, coder, not FLAGS.single_look)
  batch_results = sess.run(softmax_output, feed_dict={images:image_batch.eval()})
  output = batch_results[0]
  batch_sz = batch_results.shape[0]
  for i in range(1, batch_sz):
      output = output + batch_results[i]
  
  output /= batch_sz
  best = np.argmax(output)
  best_choice = (label_list[best], output[best])
  Guess = 'Guess @ 1 %s, prob = %.2f' % best_choice
  print('Guess @ 1 %s, prob = %.2f' % best_choice)
  faces_pred = dict()
  faces_pred =  {"face_pred": Guess}
  with open('pred.json', 'w') as fp:
      json.dump( faces_pred, fp)
  
  nlabels = len(label_list)
  if nlabels &gt; 2:
      output[best] = 0
      second_best = np.argmax(output)
  
      print('Guess @ 2 %s, prob = %.2f' % (label_list[second_best], output[second_best]))
  return best_choice
  </code></pre>
  
  <p>I am interesting only in all output's of Guess 1! 
  Thank you for your time :3</p>
  
  <p>UPD---------
  Inside json file, after run my program, have this output:</p>
  
  <pre><code>{"face_pred": "Guess @ 1 (60, 100), prob = 0.75"}
  </code></pre>
  
  <p>That's correct, but only for one face (i have 3+ Guess @ 1). It's not adding new data in json file, just rewriting it!</p>
  
  <p>UPD2--------
  How it looks like is console:</p>
  
  <ul>
  <li>Running file ./frontal-face-1.jpg</li>
  <li>Running multi-cropped image</li>
  <li>Guess @ 1 (60, 100), prob = 0.95</li>
  <li>Guess @ 2 (4, 6), prob = 0.02</li>
  <li>Running file ./frontal-face-2.jpg</li>
  <li>Running multi-cropped image</li>
  <li>Guess @ 1 (60, 100), prob = 0.75</li>
  <li>Guess @ 2 (38, 43), prob = 0.12</li>
  <li>ubuntu@ubuntu122:~/roman/IWAdector$</li>
  </ul>