const fs = require("fs");
fs.readFile('file.txt', (err, data) => {
if (err) {
throw err;
}
let fileRows = data.toString().split('\n');
let firstRow = fileRows.shift();
fileRows.push(firstRow);
const fileData = new Uint8Array(Buffer.from(fileRows.join('\n')));
fs.writeFile('file.txt', fileData, (err) => {
if (err) {
throw err;
}
});
});