Question: how to remove newline for csv format?

interface(prettyprint=2):
with(ListTools):
with(StringTools):
for xx from 1 to 2 do
xx := 1:
Source := FileTools[Text][ReadFile](cat("C:\\hello\\probability1-200-26042020\\home\\probability",xx,"\\probability",xx,".txt")):
openindex := [SearchAll("[",Source)]:
endindex := [SearchAll("]",Source)]:
beforefiltered := []:
for mm from 1 to nops(openindex) do
if mm > 27 then
beforefiltered := [op(beforefiltered), Chop(substring(Source, openindex[mm]..endindex[mm]))]:
end if:
od:
afterfiltered := []:
for mm in beforefiltered do
if Has(mm,"--") or Has(mm,"|") or Has(mm,"{") or Has(mm,"}") then
dummy := 0:
elif Has(mm,"Root") then
dummy := 0:
else
afterfiltered := [op(afterfiltered),mm]:
end if:
od:
afterfiltered[1];

however after chop still has new line, can not make a beautiful csv format, 

"[b(t,k)+ a
(t,k)*
x(t,k)]"

# I try to export to text first and then use Excel to use "|" as delimiter instead comma as delimiter,
#because b(t,k) has comma "," will separate to open a new column

appendto("C:\\Users\\Student\\Documents\\IQ1-200csv.txt"):
for mm in afterfiltered do
AA := parse(mm):
lprint(xx,"|","hello := [","|",AA[1],"|",AA[2],"|","]:");
od:
od:

Expect csv in format
1,b(t,k)+a(t,k)*x(t,k)
2,a(t,k)+s(t,k)*z(t,k)

Please Wait...