Let $x \in X$ be a closed point. Let $U \subset X$ be an affine open neighbourhood of $x$. Write $U = \Spec(A)$ and let $\mathfrak m \subset A$ be the maximal ideal corresponding to $x$. Set $Z = X \setminus U$ and $Z' = Z \cup \{x\}$. By Schemes, Lemma \ref{schemes-lemma-reduced-closed-subscheme} there are quasi-coherent sheaves of ideals $\mathcal{I}$, resp.\ $\mathcal{I}'$ cutting out the reduced closed subschemes $Z$, resp.\ $Z'$. Consider the short exact sequence $$ 0 \to \mathcal{I}' \to \mathcal{I} \to \mathcal{I}/\mathcal{I}' \to 0. $$ Since $x$ is a closed point of $X$ and $x \not \in Z$ we see that $\mathcal{I}/\mathcal{I}'$ is supported at $x$. In fact, the restriction of $\mathcal{I}/\mathcal{I'}$ to $U$ corresponds to the $A$-module $A/\mathfrak m$. Hence we see that $\Gamma(X, \mathcal{I}/\mathcal{I'}) = A/\mathfrak m$. Since by assumption $H^1(X, \mathcal{I}') = 0$ we see there exists a global section $f \in \Gamma(X, \mathcal{I})$ which maps to the element $1 \in A/\mathfrak m$ as a section of $\mathcal{I}/\mathcal{I'}$. Clearly we have $x \in X_f \subset U$. This implies that $X_f = D(f_A)$ where $f_A$ is the image of $f$ in $A = \Gamma(U, \mathcal{O}_X)$. In particular $X_f$ is affine. \medskip\noindent Consider the union $W = \bigcup X_f$ over all $f \in \Gamma(X, \mathcal{O}_X)$ such that $X_f$ is affine. Obviously $W$ is open in $X$. By the arguments above every closed point of $X$ is contained in $W$. The closed subset $X \setminus W$ of $X$ is also quasi-compact (see Topology, Lemma \ref{topology-lemma-closed-in-quasi-compact}). Hence it has a closed point if it is nonempty (see Topology, Lemma \ref{topology-lemma-quasi-compact-closed-point}). This would contradict the fact that all closed points are in $W$. Hence we conclude $X = W$. \medskip\noindent Choose finitely many $f_1, \ldots, f_n \in \Gamma(X, \mathcal{O}_X)$ such that $X = X_{f_1} \cup \ldots \cup X_{f_n}$ and such that each $X_{f_i}$ is affine. This is possible as we've seen above. By Properties, Lemma \ref{properties-lemma-characterize-affine} to finish the proof it suffices to show that $f_1, \ldots, f_n$ generate the unit ideal in $\Gamma(X, \mathcal{O}_X)$. Consider the short exact sequence $$ \xymatrix{ 0 \ar[r] & \mathcal{F} \ar[r] & \mathcal{O}_X^{\oplus n} \ar[rr]^{f_1, \ldots, f_n} & & \mathcal{O}_X \ar[r] & 0 } $$ The arrow defined by $f_1, \ldots, f_n$ is surjective since the opens $X_{f_i}$ cover $X$. We let $\mathcal{F}$ be the kernel of this surjective map. Observe that $\mathcal{F}$ has a filtration $$ 0 = \mathcal{F}_0 \subset \mathcal{F}_1 \subset \ldots \subset \mathcal{F}_n = \mathcal{F} $$ so that each subquotient $\mathcal{F}_i/\mathcal{F}_{i - 1}$ is isomorphic to a quasi-coherent sheaf of ideals. Namely we can take $\mathcal{F}_i$ to be the intersection of $\mathcal{F}$ with the first $i$ direct summands of $\mathcal{O}_X^{\oplus n}$. The assumption of the lemma implies that $H^1(X, \mathcal{F}_i/\mathcal{F}_{i - 1}) = 0$ for all $i$. This implies that $H^1(X, \mathcal{F}_2) = 0$ because it is sandwiched between $H^1(X, \mathcal{F}_1)$ and $H^1(X, \mathcal{F}_2/\mathcal{F}_1)$. Continuing like this we deduce that $H^1(X, \mathcal{F}) = 0$. Therefore we conclude that the map $$ \xymatrix{ \bigoplus\nolimits_{i = 1, \ldots, n} \Gamma(X, \mathcal{O}_X) \ar[rr]^{f_1, \ldots, f_n} & & \Gamma(X, \mathcal{O}_X) } $$ is surjective as desired.