Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Append to a file 

Massive success again! But wait a minute, if you observed really closely, you may have figured out, that the second time the contents of the file overwrote what the file already had from the first time. That means any time we write to a file, we first delete it's contents and we write on a white canvas from the beginning.

But what if i don't want to delete the content the file currently has? What if i just want to add content to the already existing one?

Then instead of the fs.writeFile (or fs.writeFileSync and it's equivalent functions) we use the fs.appendFile (fs.appendFileSync etc) and wrap it into a promise.

This will append the content to the content of the existing file, or it will even create a file from scratch if this file does not exist! Pretty cool uh?