I made two scripts to make a file and write in it.
The Problem is both are slow (based on Disk Speed)
Is there a better Method to write to a file?

```
let codes = [];
function makeid(length) {
   var result           = '';
   var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
   var charactersLength = characters.length;
   for ( var i = 0; i < length; i++ ) {
      result += characters.charAt(Math.floor(Math.random() * charactersLength));
   }
   return result;

};

for (let i = 0; 1000000 > i; i++)
{
   codes.push(`${makeid(20)}`);
}
fs.writeFile(`./codes/${makeid(5)}.txt`, codes.join('\n'), (err) => {
   if (err)
   {
       message.reply("There was an error processing your request");
       throw err;
   }
}) 
/* Second script */
let stream = fs.createWriteStream(`./codes/${makeid(5)}.txt`);
for (let i = 0; 1000000 > i; i++)
{
   stream.write(`${makeid(20)}`);
}
stream.end();

```

Both Codes take 5-15 seconds.
I'm looking for a faster method to make it in < 5 seconds.
The file is saved in a txt.
Thanks!