Exercise 12.3 of the Gortz and Wedhorn book says that if $f:X \to Y$ is a closed map between two schemes and $y\in Y$ is a point such that $f^{-1}(y)$ is contained in some open affine subspace of $X$ then there is an open neighborhood $U$ of $y$ such that the morphism $f:f^{-1}(U)\to U$ is affine.
I can't solve this problem and my main problem is that why if you take an open affine neighborhood of $y$ then I'm not sure why there exist an open affine neighborhood of $f^{-1}(y)$ inside $f^{-1}(U)$. I can prove that this is equivalent to the problem.
this is problem three and we don't even have any finiteness condition so It shouldn't be hard but I don't have any idea. any help is appreciated.
Let $V \subset X$ be an open affine subset containing $f^{-1}(y)$. Then $F=X\backslash V$ be a closed subset of $X$, so that $U_1=Y \backslash f(F)$ is an open subset of $Y$ containing $y$.
Let $U \subset U_1$ be an affine open subset containing $y$: then $f^{-1}(U)=X \times_Y U=V \times_Y U$.
Assume $Y$ is separated, then $V \times_Y U \rightarrow V\times_{\mathbb{Z}} U$ is a closed immersion to an affine scheme so that $V \times_Y U=f^{-1}(U)$ is affine.