closed immersion onto an affine scheme - showing affineness

Let $A$ be a ring, $X=\operatorname{Spec}A$ and $f: Z \rightarrow X$ a morphism of schemes such that i) $f$ is a homeomorphism of topological spaces and ii) $f^{\#}:\mathcal{O}_X \rightarrow f_* \mathcal{O}_Z$ is a surjective morphism of sheaves.

Question 1: How can we show that $Z$ is an affine scheme?

I am trying to follow the hint of exercise II.3.11(b) in Hartshorne, but i am getting stuck: i can show that $Z$ can be covered by a finite number of $\operatorname{Spec}B_i$ and each $\operatorname{Spec}B_i$ can be covered by finitely many $D(\phi_i(a_{ij}))$, where $a_{ij} \in A$, and $\phi_i: A \rightarrow B_i$ is the ring homomorphism that corresponds to the restriction of $f$ to $\operatorname{Spec}B_i$. Now, if i am to apply exercise II.2.17(b), i would need to show that each of the $Z_{\phi(a_{ij})}$ is affine, where $\phi: A \rightarrow \Gamma(Z,\mathcal{O}_Z)$ is the ring homomorphism of global sections.

Question 2: Any ideas how we can show that $Z_{\phi(a_{ij})}$ is affine?

Question 3: Alternatively, i have been able to show that each $\operatorname{Spec}B_i$ is isomorphic as a scheme with $\operatorname{Spec}(A/I_i)$, where $I_i$ is the kernel of $\phi_i$. Any ideas how to continue for there?

Take an affine open covering of $Z$ by principal open sets, which will come from principal open sets in $X$. Extend to a covering of $X$ by adding principal open sets. $X$ is quasi-compact since it is affine, so this is a finite covering. Now we have a finite covering of $X$ by principal opens $D(f_i)$ so $f_1, \dots, f_r$ generate the unit ideal of $A$.

Each $Z_{f}$ is a principal open subset of $D(f) \cap Z$, since $Z_f = X_f \cap Z$ and $D(f) = X_f$. $D(f) \cap Z$ was affine, therefore, $Z_f$ is affine.

Ex 2.17b (affineness criterion) applies to show that $Z$ is affine.

As shown, $Z = \text{Spec } B$. By Ex 2.18d now, the map of rings $A \to B$ is surjective. By the Isomorphism Theorem, then we know that $B \cong A / I$.

• Ex 2.17b tells you that the scheme is affine provided that the distinguished open sets are affine and the elements generate the unit ideal. – Future Mar 18 '16 at 19:52
• You can also use a different affineness criterion: if a scheme admits a finite affine covering $(U_i)$ such that $U_i \cap U_j$ also has a finite affine covering, then the scheme is affine. – Future Mar 18 '16 at 20:01
• They are principle open subsets of affine space $D(f_i)$. – Future Mar 18 '16 at 20:03
• For a general scheme $X$, $X_f$ is supposed to be a generalized version of $D(f)$ for affine schemes. – Future Mar 18 '16 at 20:07
• I edited the answer adding both the line of reasoning I explained in above comments and also a new one that tries to incorporate Ex 2.16. I am confident in the reasoning in comments, but I just thought of the Ex 2.16 reasoning so let me know if you feel there is an error in it. – Future Mar 18 '16 at 20:25