Don't leak file descriptors on error.