Script makes a new line on every loop

Hi guys, I have a code:

:local listName "rdp_blacklist"; 
:local fileName "test.txt"; 

:local script2write  "
	:local counter;
	:foreach counter in= [/ip firewall address-list find list=$listName] do={
		:local ip [/ip firewall address-list get \$counter address];
		:put \$ip;
	};
";
:put $script2write;
:execute script=$script2write file=$fileName;

as a result, I have every IP on a new line. Notepad++ shows /r/n in the end of every line. Where do they pour in?

Not sure what your goal is. For me this give a text file with one IP pr line. And you need what?

No need for semicolon ; at the end of each line, only between commands on the same line.

Every :put automatically adds a newline.
Instead, you could build a string in a variable by adding the new item to the string in the loop.
However, note that the maximum length of a string in RouterOS is 4096.

This is an instance. I need the way to put incapsulated (to prevent 4096 bytes limit) in local:script2write data in a single line. Tried both, colon doesn’t affect anything in this case (I’m new to routerOS scripting)

The data is incapsulated into local:script2write for a reason of 4096 limit. Is there any other way?

RouterOS is quite limited in handling large amounts of data. You would need to change some other part of your system so the newlines do not matter.
You also see these problems when reading data from a file. There is no “open/loop read until EOF/close” construct in RouterOS scripting, you can only read all data in one go and then you encounter the 4096 byte limit again.
Notice that scripting is mostly for handling some simple events and adding some flexibility, it is not intended and not capable of writing complex applications that process data.
There used to be a better programming language (lua) for that, but it was removed at some version way in the past.

got it, thanx