# When is the cokernel of a homomorphism of flat sheaves flat?

Let $X\to S$ be a scheme and let $D'$ and $D$ be relative effective Cartier divisors on $X$ satisfying $D' \subset D$ and let $D''$ satisfy $D = D' + D''$. Let $$0 \to \mathscr{O}_X(D'') \to \mathscr{O}_X(D) \to \mathscr{L} \to 0$$ be the induced exact sequence of sheaves on $X$. Of course $\mathscr{O}_X(D')$, $\mathscr{O}_X(D'')$ and $\mathscr{O}_X(D)$ are flat, but

Question: Is $\mathscr{L}$ necessarily flat? If not, when does flatness fail.

A colleague of a colleague has said that a positive answer (i.e. that $\mathscr{L}$ is indeed flat) is "at the beginning of Katz-Mazur", and I presume he is referring to Section 1.3, but I don't see how to derive the result from the material there. Section 1.3 is where the existence of the relative effective Cartier divisor $D''$ such that $D = D' + D''$ is stated, from which we can derive the exact sequence $$0 \to \mathscr{O}_X(D'') \to \mathscr{O}_X(D) \to \mathscr{O}_X(D) \otimes \iota_*\mathscr{O}_{D'} \to 0$$ by tensoring $$0 \to \mathscr{I}_{D'} \to \mathscr{O}_X \to \iota_*\mathscr{O}_{D'} \to 0$$ with $\mathscr{O}_X(D)$. So it would suffice to show that $\mathscr{O}_X(D) \otimes \iota_*\mathscr{O}_{D'}$ is flat, for which it would suffice to show that $\iota_*\mathscr{O}_{D'}$ is flat. Any ideas?

-

This is in the definition of a relative effective Cartier divisor: $O_{D'}$ is flat over $S$.