do not leak a file descriptor in case of an exception