title: Correct way to signal stream complete
body: <p>I've created a function to pipe data into a file and output individual files for each line of data. However, there are 35K lines of data to compile and although the code below signals "done" after about 5 mins, the files are still processing. I can't start the next function until this one is completed so I need to know when it has actually finished. </p>
  
  <pre><code>function createLocations(done) {
  if (GENERATE_LOCATIONS) {
  
      for (var i = 0; i &lt; locations.length; i++) {
          var location = locations[i],
             fileName = 'location-' + location.area.replace(/ +/g, '-').replace(/'+/g, '').replace(/&amp;+/g, 'and').toLowerCase() + '-' + location.town.replace(/ +/g, '-').replace(/'+/g, '').replace(/`+/g, '').replace(/&amp;+/g, 'and').toLowerCase();
          gulp.src('./templates/location-template.html')
              .pipe($.rename(fileName + ".html"))      
              .pipe(gulp.dest('./tmp/'));
          }
      }
      done();
      console.log('Creating '+locations.length+' Files Please Wait...');
  }
  </code></pre>
  
  <p>The function runs for a further 15mins after it has signalled done. Appreciate any help to detect the actual completion of the function.</p>
  
  <p>Many thanks!</p>