The following excerpt from the switcap backend shows the start of the entry point function and shows the output file being opened. At the end of the function, the output file is closed.
;; --------------------------------------- ;; Switcap netlist generation -- top level ;; --------------------------------------- (define switcap (lambda (output-filename) (let ((port (open-output-file output-filename))) ;; rest of netlisting goes here ;; close the output file and return (close-output-port port))))