Help save to txt file

hi guys, I need to save the status of some of my sensors in a txt file but every time I save the file it is written continuously and not at a new line, example:
2024-02-27, 14:35 | 10.92 | 4.45 |
2024-02-27, 14:37 | 10.92 | 4.45 |

not 2024-02-27, 14:35 | 10.92 | 4.45 | 2024-02-27, 14:37 | 10.92 | 4.45 |
this is the code I use in automation:
action:

  • service: notify.salva_finanza
    data:
    message: >-

    {{ states('sensor.date_time') }} | {{
    states('sensor.total_garage1_month')}} |
    {{states('sensor.total_garage_montly2')}}
    

ha’s jinja implementation is configured to strip trailing and leading new lines. i haven’t found a way around it. but if this is just for your own logging, i add a character after the new line. something like this:

{{ states('sensor.date_time') }} | {{
states('sensor.total_garage1_month')}} |
{{states('sensor.total_garage_montly2')}}  
{{ '\n' }} |

yeah, i know it’s an obvious hack… until someone more knowledgeable knows a way. would love to know too!