Don't close file object if we were given one rather than a filename