(defun foo (in out process-sexpr) "Read s-expressions from the stream IN, process them one by one using the function PROCESS-SEXPR and print the results to the steram OUT." (do ((sexpr (read in nil :eof) (read in nil :eof))) ((eq sexpr :eof)) (print (funcall process-sexpr sexpr) out)))

;;; Example: send all the s-exprs from a file to stdout.(with-open-file (in "test.txt") (foo in t #'identity))

You could write your own basic reader. If the files you're processing are just basic sexprs, without fancy read-table stuff going on, then a basic reader is really pretty simple to build. You could do it such that you parse the file while retaining the comments. Not ideal, surely, but once you are able to get the file contents into memory as lists, it will be much easier to fiddle with them.