title: How can I read the contents of a file into a list in Lisp?
body: <p>I want to read in the contents of a file into a list. Some of my attempts so far have been -</p>
  
  <pre><code>(defun get-file (filename)
    (let ((x (open filename)))
      (when x
        (loop for line = (read-line x nil)
       while line do (list line)))
      (close x)))
  
  (defun get-file (filename)
    (let ((x (open filename :if-does-not-exist nil)) (contents (list nil)))
      (when x
        (loop for line = (read-line x nil)
       while line do (cons contents line)))
      (close x) contents))
  
  (defun get-file (filename)
    (let ((x (open filename :if-does-not-exist nil)) (contents nil))
      (when x
        (loop for line = (read-line x nil)
       while line do (append contents line)))
      (close x) contents))
  </code></pre>
  
  <p>None of these worked. Can anyone tell me a way? Or even better - how to put all of the contents into an array?</p>