Saving data from arduino to a text file

I built a circuit that detects tempretuares from 5 different places using an Arduino nano.

Then I used Serial port library in Javascript to read the data in the Terminal(I’m using a Mac).

I can read the data in the terminal now but I’m trying to save the data to a text file but it’s not working.
I using node.js but no luck

Here is my javascript code

var SerialPort = require('serialport');
var Readline = SerialPort.parsers.Readline;
var port = new SerialPort('/dev/cu.usbserial-A505BRMT');
var parser = new Readline();
parser.on('data', console.log);
port.write('ROBOT PLEASE RESPOND\n');

// Creating the parser and piping can be shortened to
var parser = port.pipe(new Readline());

var fs = require('fs')
var readingTotextfile = port.pipe(parser);
fs.appendFile('message.txt', 'My file', function(err) {
  console.log('The "data to append" was appended to file!');

in my messeage.txt file I only see this “My file”. I tried different things some times I saw [object Object]
and other time is saw random things

After I get the data to be saved in a text file, I want to use a chart library to make a graph of my data.

Any help would be great

Any proper terminal programme should be able read serial data direct from Arduino, just like the serial monitor in the Arduino IDE, and record it to a text file - all without any messing with Arduino code. I recognise that you are using a mac, but I can’t believe you cannot do the same thing.

Such a file can be opened in Excel and a chart made therefrom.

Try using FileZilla.