The Algebraic Hartogs Lemma states that in a Noetherian normal scheme, a rational function that is regular outside a closed subset of codimension at least two, is in fact regular everywhere.
In a research problem I was working on recently, I was (following suggestions by my advisor) using this to prove that a particular section of a line bundle existed on a space $\mathbb{A}^n_H$. The argument worked well when $H$ was a point. For more general $H$, I could show that the section was defined except on a codimension-two subset of every fiber; but it was not immediately obvious to me how to go from there, to showing that the section was defined "on all fibers simultaneously," i.e., over $\mathbb{A}^n_H$. This was especially problematic in that the base scheme $H$ in question was a component of a Hilbert scheme, and thus (as shown by Ravi Vakil) capable of exhibiting arbitrarily bad behavior. In particular, the fact that a composition of normal morphisms is normal (see EGA IV.2, section 6.8) would not come close to covering my situation.
In order to deal with this, I have obtained what seems to be a proof of the following statement:
Lemma (Relative Algebraic Hartogs' Lemma) Let $X \to S$ be a flat, finite-type morphism of Noetherian schemes such that every associated fiber is normal. Let $\mathscr{L}$ be a line bundle on $X$. Suppose that $U \subset X$ is an open subscheme such that
(i) $U$ contains all the associated points of $X$,
(ii) for every $s \in S$, $U \cap X_s$ contains all the associated points of $X_s$, and
(iii) for every associated point $\eta$ of $S$, $U$ contains all but a codimension-two closed subset of $X_{\eta}$.
Then the restriction map $$\Gamma(X,\mathscr{L}) \to \Gamma(U,\mathscr{L})$$ is an isomorphism.
(I'm using "associated fiber" to mean "fiber over an associated point," by analogy with the standard term "generic fiber.")
I should note that suggestions of Will Sawin in this answer were invaluable in coming up with the proof.
This lemma is surprisingly strong, in that two key hypotheses--normality, and codimension-two-ness--only need to hold "generically" (i.e., in the fibers over the associated points). Another interesting feature is that, if you look at the proof, the fibers do not actually have to be normal, as long as they "satisfy the Hartogs property"--which I understand is equivalent to satisfying the S2 condition. I'm also not convinced that the finite-type hypothesis is necessary, but I have not yet verified the argument that I suspect would remove it.
The proof is not incredibly long (4 pages from me; probably less from a more experienced mathematician who knows what details to leave out), uses only techniques that are extremely well known, and so far as I can tell, does not use them in an especially clever way. Thus, it seems likely that someone, at some point, has already written up a similar result. However, neither I, nor my advisor, nor anyone else I have spoken to was familiar with it (which suggests to me that, if nothing else, the result is less well-known than it should be). Hence, my question:
Question: Does anyone know of a similar statement in the literature? (To be safe, I'll also ask if anyone knows of any counterexamples, although I think the proof is solid.)
One final note: From what I understand, the popularity of the name "algebraic hartogs lemma" is quite recent, possibly a result of its use in Ravi Vakil's notes, so a similar result in the older literature would probably not be called by the word "Hartogs."
Update: I have posted a proof of the Lemma above.