title: Why isn't my http.createServer working in NodeJS?
body: <p>I need help with my NodeJS code. The program is working but my server is not being created. Any ideas why? The problem is, I suspect my fs.readFile and fs.writeFile are generating errors, but that doesn't make sense because it would log them. Also, is there something wrong with my http.createServer syntax, like a problem with the res.writeHead?</p>
  <p>My code is here:</p>
  <pre><code>
  let http = require(&quot;http&quot;);
  let fs = require('fs');
  let readline = require(&quot;readline&quot;);
  let rl = readline.createInterface({
      input: process.stdin,
      output: process.stdout
  });
  
  rl.question(&quot;Do you have an html file here? y/n &quot;, function(bool) {
    if (bool == &quot;y&quot;) {
      rl.question(&quot;What is its name? &quot;, function(file) {
        fs.readFile(file, (err, data) =&gt; {
          if (err) console.log(err);
          rl.question(&quot;What code to add? &quot;, function(additionalData) {
            
            http.createServer((req, res) =&gt; {
              res.writeHead(200, {'Content-Type': 'text/html'});
              res.write(data + additionalData);
              res.end();
            })
            fs.writeFile(file, data + additionalData, err =&gt; {
              if (err) console.log(err);
            })
          })
        })
      })
    }
    else {
      rl.question(&quot;New file name: &quot;, function(name) {
        rl.question(&quot;Data: &quot;, function(data) {
          fs.writeFile(name, data, err =&gt; {
            if (err) console.log(err);
          })
          fs.readFile(name, (err, data) =&gt; {
            if (err) console.log(err);
            http.createServer(function(req, res) {
              res.writeHead(200, {'Content-Type': 'text/html'});
              res.write(data);
              res.end();
            })
          })
        })
      })
    }
  })
  
  </code></pre>