inserting crlf into text file

Hi
I’ve got the following script to write the usage of our clients on the usermanager to a file but the output is one long string. I would like to insert a crlf after each client so that I can import it into exel. I tried /r/n but that does’nt work If anyone can give me a pointer on how to do this

:local downloadlused
:local uploadused
:local client
:local newtext
:local oldtext
/file set usage.txt contents=“”
/tool user-manager user
:foreach i in=[/tool user-manager user find subscriber=admin] do={
:set client [get $i name]
:set uploadused [get $i upload-used]
:set uploadused [:tostr $uploadused]
:set downloadlused [get $i download-used]
:set downloadlused [:tostr $downloadlused]
:set oldtext [/file get [/file find name=usage.txt] contents]
:set newtext ($oldtext . " " . $client . “,” . $uploadused . “,” . $downloadlused)
/file set usage.txt contents=$newtext
}

Thanks guys

The escape code for crlf is “\n”. Like this:

:set newtext ($oldtext . "\n" . $client . "," . $uploadused . "," . $downloadlused)

It produces an output like this.

/nuser1,432144,545422/nuser2,8926069,80082044/nuser3,520311629,3529277308/nuser4,412520988,1554555323/nuser5,33844981,127074590/nuser6,1539238757,4064530441/nuser7,73536214,232673237

I need it to be like this

user1,432144,545422
user2,8926069,80082044
user3,520311629,3529277308
user4,412520988,1554555323
user5,33844981,127074590
user6,1539238757,4064530441
user7,73536214,232673237

thanks

Looks like you’re using /n rather than \n.

Wow thanks Fewi you’re the best

Nah, Tim had it.

Technically:

CR = \r
LF = \n

CRLF = \r\n

Windows formats documents using CRLF, whereas unix/linux mostly only use LF.
Mikrotik console also uses CRLF to format output.

Ex.
:put “test1\ntest2”

test1
     test2

:put “test1\rtest2”

test2

:put “test1\r\ntest2”

test1
test2

Hope this helps.