text: const fs = require('fs');
  const { promisify } = require('util');
  
  // callback hell version
  const callbackHell = file => {
    const buf = Buffer.from('Callback hell first string\n');
    const buf2 = Buffer.from('Callback hell second string\n');
  
    // write or append the contents of the first buffer
    fs.writeFile(file, buf, err => {
      if (err) {
        console.log(err);
        throw err;
      }
      // append the contents of the second buffer
      fs.appendFile(file, buf2, err2 => {
        if (err2) {
          console.log(err2);
          throw err2;
        }
        // log the contents of the file
        fs.readFile(file, 'utf-8', (err3, data) => {
          if (err3) {
            console.log(err3);
            throw err3;
          }
          console.log(data);
        });
      });
    });
  };
  
  callbackHell('./files/callback.txt');
  
  // async / await version
  const writeFile = promisify(fs.writeFile);
  const appendFile = promisify(fs.appendFile);
  const readFile = promisify(fs.readFile);
  
  const fileWriteRead2 = async file => {
    const buf = Buffer.from('The first string\n');
    const buf2 = Buffer.from('The second string\n');
  
    // write or append the contents of the first buffer
    try {
      await writeFile(file, buf);
    } catch (error) {
      console.log(error);
      throw error;
    }
  
    // append the contents of the second buffer
    try {
      await appendFile(file, buf2);
    } catch (error) {
      console.log(error);
      throw error;
    }
  
    // log the contents of the file
    console.log(await readFile(file, 'utf8'));
  };
  
  fileWriteRead2('./files/async.txt');
  