Error before writing output during fit