Rewrite a file locally

Hello everybody
From an “input type = file” tag I retrieve the content of a local text file, therefore chosen by the user.
I modify this content retrieved in a string, and I would like to rewrite this file locally, so as to have the file modified locally.
Could someone show me how to do this

  <h1>Welcome to Prjtest!</h1>
  <input type="file" id="myFile">
  <textarea style="width:500px;height: 400px" id="output"></textarea>
Template.body.rendered = function() {
    let input = document.getElementById("myFile");
    let output = document.getElementById("output");
    input.addEventListener("change", function () {
        if (this.files && this.files[0]) {
            let myFile = this.files[0];
            let reader = new FileReader();
            reader.addEventListener('load', function (e) {
                output.textContent =;

thank you

This isn’t currently possible due to very obvious security concerns. In the future, the File system access API is a possibility File System Access

Until then your only option is to trigger a download of the file which will put it in the downloads folder

Thanks for your quick answer
I do understand that this could pose security concerns, but I thought that since the file was chosen by the user, there was no risk.
I will be closely monitoring the evolution of the File System Access API
Thank you for your answer.