I am trying to append a string to a log file. However writeFile will erase the content each time before writing the string.
fs.writeFile(\'log.txt\'
Try to use flags: 'a' to append data to a file
flags: 'a'
var stream = fs.createWriteStream("udp-stream.log", {'flags': 'a'}); stream.once('open', function(fd) { stream.write(msg+"\r\n"); });