title: fs.appendfile does not work when in foreach loop
body: <p>I am trying to write a some content to each file in a directory. My idea is to read the directory and list all the files in the directory.</p>
  
  <p>Then for each file append the location of the file in the text file as string.</p>
  
  <p>For example: Directory contains 2 files, Sample2.content1.txt, Sample2.content2.txt.</p>
  
  <p>I want to read the sample1.content1.txt and write its location within the file as location-c:\sample1.txt.</p>
  
  <p>The format of the text in file is </p>
  
  <pre><code>Page 0 -/text.php
  Page 1 -/60893.php
  Page 2 -/1189.php
  Page 3 -/20389.html
  </code></pre>
  
  <p>I am working on this but am stuck at why the append file does not write the content to file.</p>
  
  <pre><code>var fs = require('fs');
  fs.readdir('C:/Users/Administrator/Desktop/Project/output',function(err,data)
  {
       if(err) throw err;
       data.forEach(function(file){
           //console.log('C:/Users/Administrator/Desktop/Project/output'+file)
           fs.appendFile('C:/Users/Administrator/Desktop/Project/output'+file,'appending this text to file','utf8',(err)=&gt;{if(err) throw err; console.log('data was appended to '+file)})
      });
   });
  </code></pre>
  
  <p>Running this does not give me any error and console.log returns:
  data was appended to sample2.content1.txt
  data was appended to sample2.content2.txt</p>
  
  <p>I wan to perform multiple actions on the file after the string is appended i.e parse the text in file and convert it to JSON format etc.</p>
  
  <p>Hope you can help me.Am new to JS and Node.</p>
  
  <p>Regards,
  Jai</p>