add missing flush in cdf write