Cant really understand what I do wrong here. Everything loops fine in the console.log but in the file I only get the last one. I quessing it is overwriting the file everytime?
readFiles('/Volumes/Staccs_Sled_001/Eagle Rock 2 Oktober - Exported', (filepath, name, ext, stat) => {
console.log('file path:', filepath);
console.log('file name:', name);
console.log('file extension:', ext);
console.log('file information:', stat);
const infotext = [
    ext,
    filepath,
]
fs.writeFileSync('./exportedTitles.json', JSON.stringify(infotext, null, 2), err => {
  if (err) {
      console.log(err);
  } else {
      console.log('files made');
  }
})
})
Any suggestions what I doing wrong?
 
    