mac address export script to file

Halo,

I want to create script which do export all mac address from leases list to file like:

create file.txt and intro file is:
11-22-33-44-55-66
aa-bb-cc-dd-ee-ff-gg


and after create this file mikrotik connect to my UniFi AP via SSH and import mac address to white list security connection.

Know this procedure alone mikrotik? Or any better idea?

:local output ""
:local filename "mac_address.txt";

:foreach i in=[/ip dhcp-server lease find] do={	
   :set output ($output . [/ip dhcp-server lease get $i mac-address] . "\n");
}
/file print file=$filename;
:delay 1;
/file set [/file find name=$filename] contents=$output;

Wow, is perfect!

Thanx

What is a language? And where I find material for learning??

Can you update your script. So it works pretty well but, what i found is when im opening the file it goes like 0C:EA:99:97:XX:XX0C:EA:99:79:XX:XX Can you change to get information like:

0C:EA:99:97:XX:XX
0C:EA:99:79:XX:XX