Emacs Lisp: Open File, Read, Possibly Write
Here's a idiom for efficiently opening a file, read content, and possibly write back to file.
(defun my-process-file (fPath) "Process the file at path FPATH" (let ((fileChanged-p nil)) (with-temp-buffer (insert-file-contents fPath) ;; process text ;; set fileChanged-p to t or nil (when fileChanged-p (write-region (point-min) (point-max) fPath)))))