Assume that $f : X \rightarrow Y$ is a morphism of schemes. Then prove that $f$ is a closed immersion if-f there is an affine cover of $Y$ say $\{ U_i \}$, such that the induced scheme morphisms $f^{-1}(U_i) \rightarrow U_i$, is a closed immersion $ \forall \thinspace i \in I$.
(The above is an exercise from Vakil's notes)