title: LISP - write a list to file
body: <p>I need to write a numeric list to a file and put a <code>return</code> at the end of the line.</p>
  
  <p>I have tried with this code but work only for the first element of the list.</p>
  
  <pre><code>(defun write-segment (filename segment)
    (cond ((null segment)
           (with-open-file (out filename 
                                :direction :output 
                                :if-exists :append 
                                :if-does-not-exist :create)
             (format out "~%")))
          (T (with-open-file (out filename 
                                  :direction :output 
                                  :if-exists :append 
                                  :if-does-not-exist :create)
               (format out "~D " (first segment))
               (write-segment filename (cdr segment))))))
  </code></pre>
  
  <p>Some one can help me to resolve this problem?</p>