title: Can I use HTML5/Javascript to load specific number of lines instead of bytes of a local file?
body: <p>I currently have some code in place to allow a user to select a local file, read in that file as text, and then output that text into a textarea. However, I would like to only read in the first N number of lines, since the files will likely be >10GB.</p>
  
  <p>I know that it is possible to read in blob of files as ranges of bytes, but I was wondering if I can read lines of text files the same way. Here is my current code:</p>
  
  <pre><code>&lt;input type="file" id="files" name="file" /&gt;&lt;br&gt;
  
  &lt;script&gt;
      function handleFileSelect(evt) {
          var files = document.getElementById('files').files;
          if (!files.length) {
            alert('Please select a file!');
            return;
          }
  
          var file = files[0];
          var reader = new FileReader();
          reader.onloadend = function(evt) {
              if (evt.target.readyState == FileReader.DONE) { // DONE == 2
                  document.getElementById('myInput').textContent = evt.target.result;
              }  
          };
          reader.readAsText(file, "UTF-8");
      }
  
  
  document.getElementById('files').addEventListener('change', handleFileSelect, false);
  </code></pre>
  
  <p>...and I have seen things like this being used:</p>
  
  <pre><code>var blob = file.slice(startingByte, endindByte);
  reader.readAsBinaryString(blob);
  </code></pre>
  
  <p>...but want lines instead of byte ranges. Thanks!</p>