title: making a JSON file from user's input
body: <p>I'm trying to use <code>JSON</code> as some kind of database for my application. So the user adds an input and it's written to the JSON file, then when I need that information I can loop through the JSON. 
  I'm using <code>'fs'</code> to write the JSON format of my object inside file:</p>
  
  <pre><code>fs.appendFile('log.json',  JSON.stringify(customer) + '\n' , function(err) {
      if (err) {
          return console.log(err);
      }
      console.log('saved in log.json');
  });
  </code></pre>
  
  <p>So my <code>log.json</code> looks like this:</p>
  
  <pre><code>{"name":"John","email":"john@gmail.com"}
  {"name":"Peter","email":"Peter@gmail.com"}
  </code></pre>
  
  <p>This is still can be used if I read each line and convert it to object, but obviously it's not a valid <code>JSON</code> file and it'd be better if I can have this as output:</p>
  
  <pre><code>{
  {"name":"John","email":"john@gmail.com"},
  {"name":"Peter","email":"Peter@gmail.com"}
  }
  </code></pre>
  
  <p>or even better:</p>
  
  <pre><code>[
  {"name":"John","email":"john@gmail.com"},
  {"name":"Peter","email":"Peter@gmail.com"}
  ]
  </code></pre>
  
  <p>So technically all I want to do is keeping <code>{}</code> and append my text inside curly braces. Please note that I can't store all of the inputs in an array/object and then write that in my log file. I want an external-module-free method to update my <code>log.json</code> file every time user enters new information.</p>