@wraps(method)
def decorator(self, *args, **kwargs):
    if self.closed:
        raise ValueError('I/O operation on closed file.')
    return method(self, *args, **kwargs)
@wraps(method)
def decorator(self, *args, **kwargs):
    if self.closed:
        raise ValueError('I/O operation on closed file.')
    return method(self, *args, **kwargs)