title: how to save files in "while" with phantomjs?
body: <p>I need to save 4 files in html output.</p>
  
  <p>here is the code in phantomjs:</p>
  
  <pre><code>var i = 0;
  
  while (i&lt;4)
  {
  var page = require('webpage').create();
  
  var fs = {};
  fs = require('fs');
  
  if(i==0)
  {
      var url = 'http://www.lamoda.ru/shoes/dutiki-i-lunohody/?sitelink=leftmenu&amp;sf=16&amp;rdr565=1#sf=16';
  
  } else {
      var url = 'http://www.lamoda.ru/shoes/dutiki-i-lunohody/?sitelink=leftmenu&amp;sf=16&amp;rdr565=1#sf=16&amp;p='+i;
  }
  
  
  page.open(url, function (status) {
      var js = page.evaluate(function () {
          return document;
      });
      console.log(js.all[0].outerHTML); 
  
      page.render('export'+i+'.png');
  
      fs.write(i+'.html', js.all[0].outerHTML, 'w');
  
      phantom.exit();
  });
  
  i++;
  }
  </code></pre>
  
  <p>It seems that I need to change the FS variable, but I don't know how... I don't need create fs1,fs2,fs3,fs4... I need to find you the better solution, hope you will help, thank you)</p>