# Checking separatedness after glueing two schemes

Let $X \to S$ and $Y \to S$ be separated morphisms of schemes and suppose that $X$ and $Y$ can be glued over an open $U \subseteq S$, in such a way that each fiber of the new morphism $Z \to S$ is completely contained in $X$, completely contained in $Y$ or completely contained in both $X$ and $Y$.

I'm pretty sure that $Z \to S$ will also be separated. But how do I prove this rigorously? In particular, can we under some additional conditions conclude that if the fibers of a morphism are separated, then the morphism itself will be separated, too?

-