Q:

LISP error in FORMAT function call

I wrote this code to write of a file:
(defun writefile (text filename)
  (with-open-file (stream filename :direction :output :if-exists :supersede
                   :if-does-not-exist :create)
    (format stream text)))

but if i execute, for example:
(writefile '(a b c) "foo.txt")

returns:

Error: In a call to FORMAT: (A B C) is not of type (OR STRING
  FUNCTION).

Why it shows me that error?

A:

Your format call is wrong:
the second argument should be either a
string or a
function (cf. the error message!)
You need to replace it with (format stream "~S" text) or just use prin1 or write.

