title: fs.readFileSync only sometimes returns a valid string in specific circumstances
body: <p>In my node application, I have an <code>init</code> function:</p>
  
  <pre><code>function init() {
      if (!fs.existsSync("../schedule.json"))
          fs.createReadStream('../template.json').pipe(fs.createWriteStream('../schedule.json'));
  
      var content = fs.readFileSync("../schedule.json", "utf8");
  
      return JSON.parse(content);
  }
  </code></pre>
  
  <p>Whenever I try to run it from cmd or git bash it crashes because of the error:</p>
  
  <blockquote>
    <p>SyntaxError: Unexpected end of JSON input</p>
  </blockquote>
  
  <p>So I debugged it in vscode and found out that the variable <code>content</code> only contained an empty string which means that <code>readFileSync</code> is returning an empty string.</p>
  
  <p>Now here is the weird thing; it never works if started in cmd or git bash (neither in regular mode or debug) or when started in debug mode in vscode but if I restart the debugger in vscode (not starting and stopping but actually hitting the restart button) then I get the correct content of the json file as a string returned from readFileSync about every other time.</p>
  
  <p>Update:
  I tried deleting the schedule.json file and then stepping through the code. It showed that it actually didn't enter the <code>if(!fs.existsSync("../schedule.json"))</code> statement.
  It's almost like a caching bug.</p>