The only reliable way to delete something in a text file is to open a new text file and copy all the content of the original file over to the new one except what you do not want to be there.
None of the operating systems that MATLAB runs on have the facility to delete in the middle of a file.
(If you were deleting only at the very end of the file, there are ways in the operating systems, but the ways are not supported by MATLAB)