title: How do I add to an existing json file in node.js
body: <p>I am new to Node.js and JavaScript. I have a <code>results.json</code> file that I want to keep a running log of results from a script that pulls images from the web. However, my current script only overwrites the existing result. How do I build upon or add to the <code>results.json</code> so each subsequent result is logged in the results.json file? I would like it to be valid json.</p>
  
  <p>Here is general example:</p>
  
  <pre><code>var currentSearchResult = someWebSearchResult
  var fs = require('fs');
  var json = JSON.stringify(['search result: ' + currentSearchResult + ': ', null, "\t");
  fs.writeFile("results.json", json);
  </code></pre>
  
  <p>And the results.json:</p>
  
  <pre><code>[
      "search result: currentSearchResult"
  ]
  </code></pre>