title: node.js/ read 100 first bytes of a file
body: <p>I'm trying to read a file in parts: the first 100 bytes and then on..
  I'm trying to read the first 100 bytes of the <code>/npm</code> file:</p>
  
  <pre><code>app.post('/random', function(req, res) {
      var start = req.body.start;
      var fileName = './npm';
      var contentLength = req.body.contentlength;
      var file = randomAccessFile(fileName + 'read');
      console.log("Start is: " + start);
      console.log("ContentLength is: " + contentLength);
      fs.open(fileName, 'r', function(status, fd) {
          if (status) {
              console.log(status.message);
              return;
          }
          var buffer = new Buffer(contentLength);
          fs.read(fd, buffer, start, contentLength, 0, function(err, num) {
              console.log(buffer.toString('utf-8', 0, num));
          });
      });
  </code></pre>
  
  <p>the output is: </p>
  
  <pre><code>Start is: 0
  ContentLength is: 100
  </code></pre>
  
  <p>and the next error:</p>
  
  <pre><code>fs.js:457
    binding.read(fd, buffer, offset, length, position, wrapper);
            ^
  Error: Length extends beyond buffer
      at Object.fs.read (fs.js:457:11)
      at C:\NodeInst\node\FileSys.js:132:12
      at Object.oncomplete (fs.js:107:15)
  </code></pre>
  
  <p>What can be the reason?</p>