Lemma 28.43.4. Let $f : X \to Y$ be a morphism of schemes. If $f$ is a homeomorphism onto a closed subset of $Y$ then $f$ is affine.

Proof. Let $y \in Y$ be a point. If $y \not\in f(X)$, then there exists an affine neighbourhood of $y$ which is disjoint from $f(X)$. If $y \in f(X)$, let $x \in X$ be the unique point of $X$ mapping to $y$. Let $y \in V$ be an affine open neighbourhood. Let $U \subset X$ be an affine open neighbourhood of $x$ which maps into $V$. Since $f(U) \subset V \cap f(X)$ is open in the induced topology by our assumption on $f$ we may choose a $h \in \Gamma (V, \mathcal{O}_ Y)$ such that $y \in D(h)$ and $D(h) \cap f(X) \subset f(U)$. Denote $h' \in \Gamma (U, \mathcal{O}_ X)$ the restriction of $f^\sharp (h)$ to $U$. Then we see that $D(h') \subset U$ is equal to $f^{-1}(D(h))$. In other words, every point of $Y$ has an open neighbourhood whose inverse image is affine. Thus $f$ is affine, see Lemma 28.11.3. $\square$

In your comment you can use Markdown and LaTeX style mathematics (enclose it like $\pi$). A preview option is available if you wish to see how it works out (just click on the eye in the toolbar).