Reading a text file and converting to form another text file

I have programming experience and am fairly new to JS would like to read a text file line by line into an array. Then convert the array elements and output to another text file. Now I am going through https://www.w3schools.com/js/default.asp

I am thinking of reading one line at a time and putting that line into array and then loop the process to read the whole file .
Lines would like this
saa-ree-|gaa-maa-|paa-daa-|nee-Saa-|

and then have a code to process the array to produce
CD|EF|GA|Bc|

Thank you

Thiru

a very small simple complete example

input

saa-ree-|gaa-maa-|paa-daa-|nee-Saa-|

Saa-nee-|daa-paa-|maa-gaa-|ree-saa-|

output

CD|EF|GA|Bc|

cB|AG|FE|DC