I am having trouble understanding the reduction to the affine case in the proof of Theorem 11.4.1 in Vakil (found here: http://math.stanford.edu/~vakil/216blog/FOAGnov1817public.pdf). The theorem says that:
If $\pi \colon X \rightarrow Y$ is a finite type morphism of irreducible $k$-varieties, with $\dim(X) = n$ and $\dim(Y) = m$, then there exists some nonempty open set $U \subseteq Y$ such that for each $q \in U$, the fiber over $q$ is either empty or has pure dimension $n - m$.
We may assume that $Y$ is affine. Then, the book states that:
We may also assume that $X$ is affine, say $Spec A$. (Reason: cover $X$ with a finite number of affine open subsets $X_1, \dots, X_a$, and take the intersection of the $U$’s for each of the $\pi |_{X_i}$.)
Why is this statement true? In particular, for $q \in Y$, if $\dim(\pi^{-1}(q) \cap X_i)$ is either empty or pure dimension $\dim(X_i) - m$ for all $i$, then why is either $\pi^{-1}(q)$ empty or is pure dimensional with $\dim(\pi^{-1}(q)) = n - m$?