title: jQuery each + FileReader not returning correct values
body: <p>I'm trying to read 2 CSV files which contains rows of numbers each.</p>
  
  <pre><code>&lt;input type="file" id="file[0]" name="file[0]"&gt;
  &lt;input type="file" id="file[1]" name="file[1]"&gt;
  </code></pre>
  
  <p>File 1 content:</p>
  
  <pre><code>111
  222
  </code></pre>
  
  <p>File 2 content:</p>
  
  <pre><code>333
  444
  </code></pre>
  
  <p>After reading the contents, I push the numbers to new array (csv_arr) and count the occurrences (csv_cnt).</p>
  
  <pre><code>var csv_arr = new Array();
  var csv_cnt = 0;
  
  $("[id^=file]").each(function(index) {
      file = $(this)[0].files[0];
  
      if (file) {
          var reader = new FileReader();
          reader.onload = function(e) {
              var csv_val = e.target.result.split("\r\n");
  
              for (var i = 0; i &lt; csv_val.length; i++) {
                  csv_arr.push( csv_val[i] );
                  csv_cnt++;
              }
          };
          reader.readAsText(file);
      }
  });
  
  console.log(csv_arr);
  console.log(csv_arr.length);
  console.log(csv_cnt);
  </code></pre>
  
  <p>The result of the console.log are:</p>
  
  <pre><code>['111','222','333','444']
  0
  0
  </code></pre>
  
  <p>As you can see from the result, the array looks ok, but then the array length and count are 0! I'm stuck and not sure what is really wrong. Any idea?</p>