I am writing some data to a file. I first generate a string with the following code:
for(var t of transactions){
outputString += t.playerID + '|' + t.equipmentID + '|' + t.transaction + '|' + this.datePipe.transform(t.transactionTime, 'MM/dd/yyyy hh:ss a') + '|\n';
}
And then I write to the file:
this.writeFileHelper('HHTransactions.txt', outputString);
....
public writeFileHelper(fileName: string, outputString: string) {
this.file.writeFile(this.baseDir + '/mobile', fileName, outputString, true).then((Result) => {
console.log(Result);
}, (error) => {
console.log(error)
});
}
When I read the file on my mobile device, the output data shows data on separate lines, which I would expect \n
to do. However, when the file is read by a PC, I end up with all the data in the same line.
Does anyone know why I am seeing this issue? I realize I can use:
writeFile(path, fileName, text, {append: true, replace: false})
But that seems silly to make a call for each record I'm writing into the file.
Thanks in advance.