title: Understanding function (err, data) callbacks
body: <p>So I am confused about how the function(err, data) callback works, is the first argument always an error handler? </p>
  
  <p>What about the remaining arguments if you had something like function (x, y, z, a, b, c)?</p>
  
  <p>How does the data from fs.readFile pass from the top line of code to the bottom line of code? Or in other words, how does the output of fs.readFile get put into the data argument?</p>
  
  <pre><code>fs.readFile(pathToFile, function (err, **data**) {
      bufferString = **data**.toString();
  </code></pre>
  
  <p>I could replace function (err, data) with function (x, y) and function (x, y, z, a, b, c)</p>
  
  <p>But only the second argument works (data and y), is this just the syntax of javascript callbacks?</p>
  
  <p>For example, this is working code to asynchronously read a file and print out the number of lines given a file:</p>
  
  <pre><code>var fs = require('fs');
  var pathToFile = process.argv[2];
  var bufferString, bufferStringSplit;
  
  function counter(callback) {
    fs.readFile(pathToFile, function (err, data) {
      bufferString = data.toString();
      bufferStringSplit = bufferString.split('\n');
      callback();
    });
  }
  
  function logMyNumber() {
    console.log(bufferStringSplit.length-1);
  }
  
  counter(logMyNumber);
  </code></pre>