It can fail for numerous reasons. The most common are probably:
In reply to Re^3: print() on closed filehandle by ikegami in thread print() on closed filehandle by Win