I just wanted to read the last line of my text file. I followed the answer on this TypeScript (Angular) - read text file line by line but the error appear and it says 'split' does not exist on type 'string | ArrayBuffer'
fileChanged(e) {
this.file = e.target.files[0];
if(this.file){
let fileReader = new FileReader();
fileReader.onload = (e) => {
console.log(fileReader.result);
var contents=fileReader.result;
for (const line of contents.split(/[\r\n]+/)){
console.log(line);
}
}
fileReader.readAsText(this.file);
}