title: PhantomJS / Javascript: download web page and write to text file
body: <p>Below code is download web page it work fine but i want to save i put code for write text file honestly i have no idea how i can do this to save file</p>
  
  <pre><code>var url = 'http://stackoverflow.com';
  var page = require('webpage').create();
  page.open(url, function(status) {
      if (status === 'success') {
          var html = page.evaluate(function() {
          return document.documentElement.outerHTML;
          });
          console.log(html);
      }
  var fs = require('fs');
     try {
      fs.write("C:\phantomjs\\qhxpZ.txt", "Message to be written to the file", 'w');
      } catch(e) {
          console.log(e);
      }   
      phantom.exit();
  });
  </code></pre>