Write to a file async
Exactly like we have done with reading the file, we will use the fs.promise module to write to a file asynchronously and don't block our script from further execution. For that we will use the fs.write function of the filesystem and will wrap it as previous into a promise (in order to avoid callback hell) as it is shown above.
Give it a go and test that your file contains what you want.