You've got a good understanding to the solution. But I have already copied the code snippet here; don't forget, I got the snippet here too, hoping it might work in my application to my taste.
For purpose of emphasis, I will follow your outlines in the last post in my response.
(1) The user gives the name of file that does not exist. So, you create that file and write the full content of your textarea. This Correct.but don't forget this works with the SAVE AS button when no such file already exists.
(2) If the file already exists, it should be overwritten (only if user wants to re-save ( that is, save the existing file again, perhaps, with another name). This pops up dialog box to enable him do the needful as he desires.
(3) Additional content to the existing file (that is, EDITING the content of the existing file) should be append (and saved) but WITHOUT SHOWING THE SAVE DIALOG BOX. This because the user is only adding to or removing from existing file (editing). So, he does not want to overwrite or change the existing file. Just like othe TEXT EDITORS, this can only work with the SAVE BUTTON.
(4) SAVE AS button pops up dialog box in order to save FILE NOT ALREADY EXISTING. SAVE button appends (and saves) to already existing file in the case of editing the file but without popping up dialog box. However, SAVE button can only POP UP DIALOG BOX IF SUCH FILE IS BEING SAVED FOR THE VERY FIRST TIME.
With your good knowledge of how TEXT EDITORS work, I do hope you quite understand the submission now. Thanks a lot for your concern. Cheers.