in reply to print() on closed filehandle
I don't want to be pedantic, but you're trying to print on a closed file handle. You've got two choices.
Without seeing your code, can't suggest anymore than that.