I would like to know if my solution to the following exercise is correct. If not, then I will be grateful for a correct argument. (I am working with varieties over an algebraically closed field, not schemes)
Exercise: Suppose that $f,g:X \to Y$ are two morphisms, where Y is separated. If $f$ and $g$ agree on some dense open subset $U \subset X$ then $f = g$.
My argument: Let $W = \{x \in X\:|\:f(x) = g(x)\}$. I know by assumption that $U \subset W$, and wish to show that $W = X$. Since $Y$ is separated, the graph of $f$ (call it $\Gamma_f$) is closed in $X \times Y$. So by continuity, the preimage $(\mathrm{id},g)^{-1}(\Gamma_f) = W$ is closed in $X$. But then $X = Cl_X(U) \subset Cl_X(W) = W \Rightarrow W = X$ as required.