Let $\{T_i \to T\}_{i \in I}$ be an fpqc covering of schemes over $S$. Set $X_i = X_{T_i} = X \times_S T_i$ and denote $\mathcal{F}_i$ the pullback of $\mathcal{F}$ to $X_i$. Assume that $\mathcal{F}_i$ is flat over $T_i$ in dimensions $\geq n$ for all $i$. Let $t \in T$. Choose an index $i$ and a point $t_i \in T_i$ mapping to $t$. Consider the cartesian diagram $$ \xymatrix{ X_{\Spec(\mathcal{O}_{T, t})} \ar[d] & X_{\Spec(\mathcal{O}_{T_i, t_i})} \ar[d] \ar[l] \\ \Spec(\mathcal{O}_{T, t}) & \Spec(\mathcal{O}_{T_i, t_i}) \ar[l] } $$ As the lower horizontal morphism is flat we see from More on Morphisms, Lemma \ref{more-morphisms-lemma-flat-locus-base-change} that the set $Z_i \subset X_{t_i}$ where $\mathcal{F}_i$ is not flat over $T_i$ and the set $Z \subset X_t$ where $\mathcal{F}_T$ is not flat over $T$ are related by the rule $Z_i = Z_{\kappa(t_i)}$. Hence we see that $\mathcal{F}_T$ is flat over $T$ in dimensions $\geq n$ by Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-after-base-change}. \medskip\noindent Assume that $f$ is quasi-compact and locally of finite presentation and that $\mathcal{F}$ is of finite presentation. In this paragraph we first reduce the proof of (2) to the case where $f$ is of finite presentation. Let $T = \lim_{i \in I} T_i$ be a directed limit of affine $S$-schemes and assume that $\mathcal{F}_T$ is flat in dimensions $\geq n$. Set $X_i = X_{T_i} = X \times_S T_i$ and denote $\mathcal{F}_i$ the pullback of $\mathcal{F}$ to $X_i$. We have to show that $\mathcal{F}_i$ is flat in dimensions $\geq n$ for some $i$. Pick $i_0 \in I$ and replace $I$ by $\{i \mid i \geq i_0\}$. Since $T_{i_0}$ is affine (hence quasi-compact) there exist finitely many affine opens $W_j \subset S$, $j = 1, \ldots, m$ and an affine open overing $T_{i_0} = \bigcup_{j = 1, \ldots, m} V_{j, i_0}$ such that $T_{i_0} \to S$ maps $V_{j, i_0}$ into $W_j$. For $i \geq i_0$ denote $V_{j, i}$ the inverse image of $V_{j, i_0}$ in $T_i$. If we can show, for each $j$, that there exists an $i$ such that $\mathcal{F}_{V_{j, i_0}}$ is flat in dimensions $\geq n$, then we win. In this way we reduce to the case that $S$ is affine. In this case $X$ is quasi-compact and we can choose a finite affine open covering $X = W_1 \cup \ldots \cup W_m$. In this case the result for $(X \to S, \mathcal{F})$ is equivalent to the result for $(\coprod W_j, \coprod \mathcal{F}|_{W_j})$. Hence we may assume that $f$ is of finite presentation. \medskip\noindent Assume $f$ is of finite presentation and $\mathcal{F}$ is of finite presentation. Let $U \subset X_T$ denote the open subscheme of points where $\mathcal{F}_T$ is flat over $T$, see More on Morphisms, Theorem \ref{more-morphisms-theorem-openness-flatness}. By assumption the dimension of every fibre of $Z = X_T \setminus U$ over $T$ has dimension $< n$. By Limits, Lemma \ref{limits-lemma-approximate-given-relative-dimension} we can find a closed subscheme $Z \subset Z' \subset X_T$ such that $\dim(Z'_t) < n$ for all $t \in T$ and such that $Z' \to X_T$ is of finite presentation. By Limits, Lemmas \ref{limits-lemma-descend-finite-presentation} and \ref{limits-lemma-descend-closed-immersion-finite-presentation} there exists an $i \in I$ and a closed subscheme $Z'_i \subset X_i$ of finite presentation whose base change to $T$ is $Z'$. By Limits, Lemma \ref{limits-lemma-limit-dimension} we may assume all fibres of $Z'_i \to T_i$ have dimension $< n$. By Limits, Lemma \ref{limits-lemma-descend-module-flat-finite-presentation} we may assume that $\mathcal{F}_i|_{X_i \setminus T'_i}$ is flat over $T_i$. This implies that $\mathcal{F}_i$ is flat in dimensions $\geq n$; here we use that $Z' \to X_T$ is of finite presentation, and hence the complement $X_T \setminus Z'$ is quasi-compact! Thus part (2) is proved and the proof of the lemma is complete.