Add variable to the end of a file

Hello,

how can I paste a variable to the a file into a new line?

This is a simple method of appending lines to a file in RouterOS:

:local content [file get YOUR_FILE contents]
:set content ("$content\r\n$YOUR_VARIABLE")
/file set YOUR_FILE contents=$content

Bear in mind there is 4KB size limitation on read/write of files with this method. If you want to overcome 4KB limitation you will have to write more complex routine for manipulating files and variables.