title: LISP: How to read content from a file and write it in another file?
body: <p>I want to write a function that has as arguments the names of the two files and copies the content from the first file to the second one.</p>
  
  <p>So far I wrote a function that reads from a file:</p>
  
  <pre><code>(defun readFile (name)
   (let ((in (open name)))
    (format t "~a~%" (read-line in))
     (close in)))
  </code></pre>
  
  <p>And a function that writes a string to a file:</p>
  
  <pre><code>(defun writeFile (name content)
  (with-open-file (stream name
      :direction :output
      :if-exists :overwrite
      :if-does-not-exist :create)
  (format stream content)))
  </code></pre>
  
  <p>Following Savantes instructions I wrote the function again and this is how it looks:</p>
  
  <pre><code>(defun read-write-to-file (input-file output-file)
  (WITH-OPEN-FILE (output-stream output-file
           :direction :output
           :if-exists :new-version
           :if-does-not-exist :create)
    (WITH-OPEN-FILE (input-stream input-file
                   :direction :input)
          (FORMAT output-stream "~a" (READ input-stream nil 'eof))
  )))
  </code></pre>
  
  <p>Now the only problem is that it doesn't read the entire file.</p>