You have a precedence problem. Use or, not ||. See perldoc perlopentut.
In reply to Re: Print on closed filehandle by Fletch in thread Print on closed filehandle by PerlingTheUK