I have this messed up code :
Code: Select all
(defun write-to-file (name content &optional c)
(with-open-file (stream name :external-format charset:iso-8859-1
:direction :io
:if-exists :overwrite
:if-does-not-exist :create )
(format stream content)) name)
(defun aiml-printer (filename)
(setf cat
(concatenate 'string
"<category>" '(#\Newline) "<pattern>MOF ~s</pattern>" '(#\Newline)
"<template>" '(#\Newline #\Newline) "</template>" '(#\Newline) "</category>"))
(loop for line = (read-line filename nil :eof)
until (eq line :eof) do
(write-to-file "test.txt" cat line)))
A
B
C
D
on each line, the output in file B will be:
Code: Select all
<category>
<pattern>A</pattern>
<template>
</template>
</category>
<category>
<pattern>B</pattern>
<template>
</template>
</category>
<category>
<pattern>C</pattern>
<template>
</template>
</category>
<category>
<pattern>D</pattern>
<template>
</template>
</category>
T.I.A