anna, you obviously are not giving us the whole script.
although shawns solution works on many cases, that is not the ultimate way.

if you can't post your whole code...
I can say that check out every file you open before this piece with filehandle "1" and close them before calling this piece.
_________________________
!

download KiXnet