Let $A\subseteq B$ be normal affine doamins over a field $k$ with same field of fractions. If the induced morphism of schemes $i^*:Spec\ B \rightarrow Spec\ A$ is an open immersion, how to prove that the complement of $Spec\ B$ in $Spec\ A$ is a divisor?

Let $Z$ be an irreducible component of the complement; its generic point corresponds to a prime ideal $\mathfrak{p}$ of $A$. Put $S:=\mathrm{Spec}(A_{\mathfrak{p}})$ and $s:=\mathfrak{p}A_{\mathfrak{p}}$. Consider the affine morphism $j: S\rightarrow \mathrm{Spec}(A)$. Then $S\smallsetminus \{s\} =j^{-1}(\mathrm{Spec}(B))$ is affine. From the local cohomology exact sequence $$ 0\rightarrow H^0(S,\mathcal{O}_S)\rightarrow H^0(S\smallsetminus \{s\} ,\mathcal{O}_S)\rightarrow H^1_{\{s\} }(S,\mathcal{O}_S)\rightarrow 0$$ we get $H^1_{\{s\} }(S,\mathcal{O}_S)\neq 0$. This implies $\mathrm{depth}(A_{\mathfrak{p}})\leq 1$, hence, since $A$ is normal, $\dim(A_{\mathfrak{p}})\leq 1$, so $\mathrm{codim}(Z)=1$.