Name: OLATOYE ISRAEL AYOMIDE
Matric number: AU24AC6527
[Link] File Assignment
This script reads text from one file, appends some text, and writes the result into a new file
const fs = require("fs");
// Read from the first file
[Link]("[Link]", "utf8", (err, data) => {
if (err) {
[Link]("Error reading file:", err);
return;
}
// Append extra text
const newData = data + "\nThis text was added by the script.";
// Write to a new file
[Link]("[Link]", newData, (err) => {
if (err) {
[Link]("Error writing file:", err);
return;
}
[Link]("New file created successfully!");
});
});