write array to file after looping node js
<p>I have yet to find a answer to my problem with the examples from questions others have asked on this. 
I wrote a little web scraper that stores data to 1 array and would like to write it (the arrays) to a file. I'm having trouble setting things up correctly.</p>

<p>I am using nodejs. Could someone write a sample that takes an array content then writes to a file. please break it down to basic, I am still new at programming.</p>

<p>Thanks the code is below</p>

<pre><code>var content = [];
var request = require('request');
var cheerio = require('cheerio');
var URL = 'http://www.amazon.com';



 request(URL, function(error, response, html){

   if (error){

       consol.log('Error:', error);
   }
   if (response.statusCode !== 200) {

       console.log('Invalid Status Code Returned:', response.statusCode);
   }

   //console.log(html);
      var $ = cheerio.load(html);


    $('td').each(function (i, element) {


        var a = $(this).next();
        var trimmed_a = a.text();

        trimmed_a = trimmed_a.trim();
        var str = trimmed_a.replace(/\s\s+/g,"");
        var newStr = str.trim();

        content.push(newStr);



    });

    console.log(content);
</code></pre>

<p>})     </p>