Proof. Let $X \to S$ be a quasi-compact immersion. We have to show the inverse image of every affine open is quasi-affine. Hence, assuming $S$ is an affine scheme, we have to show $X$ is quasi-affine. By Lemma 29.7.7 the morphism $X \to S$ factors as $X \to Z \to S$ where $Z$ is a closed subscheme of $S$ and $X \subset Z$ is a quasi-compact open. Since $S$ is affine Lemma 29.2.1 implies $Z$ is affine. Hence we win. $\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).