Step 1: Reading a Text File const fs = require('fs'); const path = require('path'); // Specify the path to the text file const filePath = path.join(__dirname, 'input.txt'); // Read the file fs.readFile(filePath, 'utf8', (err, data) => { if (err) { console.error('Error reading the file:', err); return; } console.log('File contents:'); console.log(data); }); Step 2: Creating and Writing to a New File const fs = require('fs'); // Create and write to a file fs.writeFile('example.txt', 'Hello, World!', (err) => { if (err) throw err; console.log('File created and written to!'); // Read the file fs.readFile('example.txt', 'utf8', (err, data) => { if (err) throw err; console.log('File content:', data); // Append to the file fs.appendFile('example.txt', ' How are you?', (err) => { if (err) throw err; console.log('File updated!'); // Read the updated file fs.readFile('example.txt', 'utf8', (err, updatedData) => { if (err) throw err; console.log('Updated file content:', updatedData); // Delete the file fs.unlink('example.txt', (err) => { if (err) throw err; console.log('File deleted!'); }); }); }); }); });