I try to prove that if a Noetherian scheme $X$ has each irreducible component affine, then $X$ is affine. Here's my attempted proof:
Choose an irreducible component $i:Y \to X$ and a quasi-coherent sheaf $\mathcal{F}$ on $X$. If $U = X\setminus Y$, $j:U\to X$, then we have the short exact sequence $0 \to \mathcal{F}_U \to \mathcal{F} \to \mathcal{F}_Y \to 0$, where $\mathcal{F}_U = j_!(\mathcal F|_U)$ and $\mathcal{F}_Y = i_*(\mathcal F|_Y)$. By taking the long exact sequence in cohomology we get the surjective maps \begin{align} H^p(X,\mathcal{F}_U) \to H^p(X,\mathcal{F}) \to H^p(X,\mathcal{F}_Y) = 0, \end{align} where the last group is $0$ since $Y$ is affine and $\mathcal{F}_Y$ is quasi-coherent. Hence it is enough to prove that $H^p(X,\mathcal{F}_U) = 0$ (then apply Serre's criterion for affineness). Now I want to use the fact that $\mathcal{F}_U$ is a quasi-coherent sheaf on $\overline{U}$, which has less irreducible components than $X$, and to use some induction on the number of irreducible components to get that $H^p(X,\mathcal{F}_U) = 0$.
My question is how I make rigorous this last fact. More precisely, how do I show that $H^p(\overline{U},\mathcal{F}_U|_\overline{U}) = H^p(X,\mathcal{F}_U)$?
Here are the two statements we'll need.
This can be proven by checking on stalks.
This is a direct consequence of closed immersions being affine and is an exercise earlier in Hartshorne.
Now we apply the facts. Write $k:\overline{U}\to X$ for the closed immersion. Then $\mathcal{F}_U|_{\overline{U}}=k^*\mathcal{F}_U$, so $$H^p(\overline{U},\mathcal{F}_U|_{\overline{U}}) = H^p(\overline{U},k^*\mathcal{F}_U)=H^p(X,k_*k^*\mathcal{F}_U)= H^p(X,\mathcal{F}_U)$$ per the statements in the previous paragraph.
For a more conventional solution (I'm not even sure Hartshorne ever defines $f_!$ in the text), consider the following:
Let $X=\bigcup_{1\leq i \leq n} X_i$ be a decomposition in to irreducible components with $\mathcal{I}_i$ the ideal sheaf of $X_i$. Let $I$ be a coherent ideal sheaf on $X$. Then we may form the filtration $$I\supset I\cdot \mathcal{I}_1 \supset I\cdot \mathcal{I}_1\cdot\mathcal{I}_2 \supset \cdots \supset I\cdot \mathcal{I}_1\cdots\mathcal{I}_n$$ where we rename the terms $I_0\supset I_1\supset\cdots I_n$ for ease of notation. The final term is zero by assumption that $X$ is reduced, and each subquotient $I_j/I_{j+1}$ is a coherent sheaf supported on $X_{j+1}$ which implies $H^1(X_{j+1},I_j/I_{j+1})=H^1(X,I_j/I_{j+1})$ (this uses the same fact you're asking about, proven above). After taking the cohomology of $$ 0\to I_{j+1}\to I_{j} \to I_j/I_{j+1} \to 0$$ we see that $0=H^1(X,I_n)=H^1(X,I_{n-1})=\cdots=H^1(X,I_0)=0$ and we have the desired claim.