title: learnyounode 'My First I/O' example
body: <p>This program puzzles me. The goal of this program is to count the number of newlines in a file and output it in command prompt. <a href="http://nodeschool.io/#learn-you-node">Learnyounode</a> then runs their own check on the file and sees if their answer matches your answer.</p>
  
  <p>So I start with the answer : </p>
  
  <pre><code>var fs = require('fs');
  
  var filename = process.argv[2];
  
  file = fs.readFileSync(filename);
  
  contents = file.toString();
  
  console.log(contents.split('\n').length - 1);
  </code></pre>
  
  <p>learnyounode verifies that this program correctly counts the number of new lines. But when I change the program to any of the following, it doesn't print out the same number as learnyounode prints out.</p>
  
  <pre><code>file = fs.readFileSync(C:/Nick/test.txt);
  file = fs.readFileSync(test.txt);
  </code></pre>
  
  <p>Shouldn't nodejs readFileSync be able to input an address and read it correctly?</p>
  
  <p>Lastly, this program is supposed to print out the # of newlines in a program. Why does both the correct program and learnyounode print out the same number that is different from the amount of newlines everytime I run this program? </p>
  
  <p>For example, the number of newlines in test.txt is 3. But running this program prints out a different number everytime, like 45, 15, 2, etc. Yet at the same time, it is verified as a correct program by learnyounode because both their answers match! What is going on?</p>
  
  <p>EDIT:
  test.txt looks like this</p>
  
  <pre><code>ok
  testing
  123
  </code></pre>