$f:X\rightarrow Y$ is a closed immersion iff $f:f^{-1}(U_i)\rightarrow U_i$ is a closed immersion. I came across the following property of closed immersions on Wikipedia -

A morphism $f:Z\rightarrow X$ is a closed immersion iff for some
  (equivalently every) open covering $X=\bigcup U_j$ the induced map
  $f:f^{-1}(U_j)\rightarrow U_j$ is a closed immersion.

I am having trouble with the "equivalenty every cover" part - assuming that the property of a morphism being a closed immersion holds for some open cover iff it holds for every cover I am able to prove the above result as follows -
If $f$ is a closed immersion then cover $X$ just by $X$ and we have found "some" cover of $X$ satisfying the induced map is a closed immersion.
Conversely, if there is "some" cover for which the induced map is a closed immersion then as it is true (as per the assumption I made) for every cover, we can take the cover to be $X$ and are done. (I hope this is correct!)
Now all I have to do is prove the assumption. But I have no idea where to start. 
I know this lemma - Let $X$ be a scheme and let $\mathcal P$ be a property. Suppose $\mathcal P$ satisfies the following conditions -


*

*If $\mathcal P$ is true for $\operatorname{Spec }R$ then it is true for $\operatorname{Spec }R_g$ for every $g\in R$

*If $\langle g_1,\cdots,g_n\rangle=R$ and $\mathcal P$ is true for each $\operatorname{Spec }R_{g_i}$ then $\mathcal P$ is true for $\operatorname{Spec }R$
Let $X=\bigcup U_i$ be an affine open cover of $X$ and suppose $\mathcal P$ is true for each $U_i$ then $\mathcal P$ is true for every affine open subset of $X$.
But this Lemma can only be applied for an affine open cover and Wikipedia's statement about closed immersions is for every open cover so I don't know how to prove it. Any help will be greatly appreciated.
Thank you.
 A: You are overthinking this. The approach should be the following:


*

*Assume $f$ is a closed immersion and show that it holds for any open cover. (Actually we only have to take one single open subset of $X$ and show that the induce map is a closed immersion)

*Assume it holds for one given cover. Show that $f$ is a closed immersion.
If you have done these two steps, the equivalance of "for some" and "for any" is automatically proven.
Note that the definition of a closed immersion consists of two ingredients:


*

*The topological part: $f$ gives an homemorphism of $Z$ onto a closed subset of $X$.

*The algebraic part: $\mathcal O_X \to f_* \mathcal O_Z$ is surjective.
I think proving the two statements above for the topological part should be quite clear, it does not need any knowledge of algebraic geometry or sheaf theory.
The algebraic part comes down to two statements:


*

*You can check the surjectivity of a map of sheaves locally.

*We have $(f_* \mathcal O_Z)_{|U} = f_*(\mathcal O_{Z|f^{-1}(U)})$

After reading this, you will understand, why the equivalence of "for some" and "for any" is automatically proven:
Let $P$ be any property, which an open cover of $X$ has or has not. Consider the $3$ statements:
$(a)$: $P$ holds for the open cover $X$.
$(b)$: $P$ holds for any open cover of $X$.
$(c)$: $P$ holds for some open cover $X$.
$(a) \Rightarrow (b)$ is proven in the first step. $(b) \Rightarrow (c)$ is trivial. $(c) \Rightarrow (a)$ is proven in the second step. Hence the $3$ statements are all equivalent.
A: If you are a Vakilian, here is how to do it using the affine communication lemma. First note that by 7.3.4 in Vakil's notes we have that the affine property of a morphism is affine local on the target. 
Let $X = \mathrm{Spec A}$ and $Y = \mathrm{Spec B}$, $\pi: X \to Y$. Now let $D(f) \subset Y$. Then $\pi^{-1}(D(f)) = D(\pi^{\#}(f))$. 
Suppose that $\pi^{\#}: B \to A$ is surjective. Then $B_f \to A_{\pi^{\#}(f)}$ is surjective. 
Now suppose that there exist $f_1,\dots,f_k$ in $B$ s.t $(f_1,\dots,f_k) = B$ such that for all $i$ we have that $B_{f_i} \to A_{\pi^{\#}(f_i)}$ is surjective. Then by algebra for all $a \in A$ we have there exist $n_i$ s.t ${\pi^{\#}(f_i)}^{n_i}a \in Im(\pi^{\#})$. Since $({\pi^{\#}(f_1)}^{n_1},\dots,{\pi^{\#}(f_k)}^{n_k})_{Im(\pi^{\#})} \supset \{1\}$ we have that $a \in Im(\pi^{\#})$. We have shown surjectivity of $\pi^{\#}: B \to A$.
