Why spooler got corrupted?

Hi,

Whitin my photon application, when the proper conditions are met (event or
alarm) there is the need to print certain message in the local printer, to
do that I open a existing file to fill it up with ascci characters
associated to the event or alarm present and then close the file and using
system(“lp -P txt f i l e n a m e”) instruction the file is copied to
printer spooler, in the spooler I think I have the proper set up to pass
the file to a text printer.
Apparently everything works ok, the problem arises when the printer starts
to print corrupted messages, it prints the actual message and adds part of
some others messages with no sense. If you review the file with the last
message you will see a normal description message, I mean the file message
looks ok, looks like the spooler is the one is getting corrupted. I have
seen this twice and the way to get rid of it has been shutting down the pc,
resseting the printer did not help. Probably killing the spooler and then
starting it up again would be enough but I have not try it yet.

Any one has an idea can help me to explain the problem?

Oscar