I am trying to append response of an API (Multiple Iterations) in single file

// The opts for the server, also includes the data to be written to file
let opts = {
requestName: request.name || request.url,
fileExtension: ā€˜jsonā€™,
mode: ā€˜appendFileā€™, // Change this to any function of the fs library of node to use it.
uniqueIdentifier: false,
responseData: pm.response.text()
};
pm.sendRequest({
url: ā€˜http://localhost:3000/writeā€™,
method: ā€˜POSTā€™,
header: ā€˜Content-Type:application/jsonā€™,
body: {
mode: ā€˜rawā€™,
raw: pm.response.text()
}
}, function (err, res) {
console.log(res);
});

I am using the above snippet , but the file has only response of first request and i am able to see ā€œInternal Server errorā€ -500 in all the iterations after POST operation

TypeError [ERR_INVALID_ARG_TYPE]: The ā€œdataā€ argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
at Object.writeFile (node:fs:2108:5)

The saved file under Responses folder has only response of first request