Autoscroll in ui-template html

Hello,
I'm using a file to write and read logs comming from MQTT.
This is read in an HTML "ui-template".
That's great because when the file is too long, a scroll bar is added automatically.
Is there any way to scroll down with programming ?
When a write occus, I trigger the read so I will be able to trigger the auto scroll. The read give a msg.payload to the template.
Do you have any idea how to auto scroll ? Whithin the html template or outside ?

If not possible, I can add line to the top of my file instead of an append (at the bottom). But the only way I know to append at the top is to read the file and overwite it then, while adding the line before. I guess that's bad for performance and ssd wear...

Update : I'm now using a flow variable to store logs as a a long string... At the end of each line I add a
instruction to start to a new line in the hmtl template.
However, my problem persists because the division doesn't auto scroll. Does anyone have an idea about how to auto scroll an html division in node red ? There are CSS an JS tutorials on internet but I doesn't know how to implement those here and if they will do work...