For any scheme $X$, we have a natural map $\eta_X : X \to \operatorname{Spec} \Gamma(X, \mathcal{O}_X)$, which is the unit of the global section, spectrum adjunction. I have attempted to prove that this map $\eta_X$ is an isomorphism iff $X$ is affine. My proof is below. Is it correct?
Proof: Let $f:X\to \operatorname{Spec} \Gamma(X, \mathcal{O}_{X})$ be as described above. Clearly, if $X$ is not affine, then $f$ cannot be an isomorphism, so we may move on to the converse. Thus, suppose $X$ is affine. Then $X \cong \operatorname{Spec} \Gamma(X, \mathcal{O}_{X})$ along some isomorphism, so $f \cong \operatorname{Spec} \mathrm{id}_{\Gamma(X, \mathcal{O}_{X})}$ in the arrow category. Functors preserve isomorphisms, as do isomorphisms of morphisms, so $f$ is an isomorphism (since identity maps are isomorphisms).