I am using code from JavaScript: Create and save file to save a string to a text file
var searchReplace = search.toString().replace(/":1200"/gi, /\n/);// replace a patturn with another patturn /gi is all instances /gi is non-case-sensitive 
    // Function to download data to a file, ref: https://stackoverflow.com/questions/13405129/javascript-create-and-save-file
    function saveData(data, filename, type) {
        var file = new Blob([data], { type: type });
        if (window.navigator.msSaveOrOpenBlob) // IE10+
            window.navigator.msSaveOrOpenBlob(file, filename);
        else { // Others
            var a = document.createElement("a"),
                url = URL.createObjectURL(file);
            a.href = url;
            a.download = filename;
            document.body.appendChild(a);
            a.click();
            setTimeout(function () {
                document.body.removeChild(a);
                window.URL.revokeObjectURL(url);
            }, 0);
        }
    }
    saveData(searchReplace, "output.txt", Text); //calls the save file function
- search is a string containing various text with no whitespace
Currently the text file stores the string on a single line and I would like to know how to change it to recognize certain characters as new lines or carriage returns like \n or \r
Less importantly, I would if its not too significant, like to know how to have the function update the text file if its exists rather than adding output(1).txt etc
