Need help to understand Uniqueness of Lifts theorem's proof. 
Theorem: Let $p:E \to B$ be a covering map. Fix $b_0 \in B$ and $e_0 \in p^{-1}(b_0)$. Let $f: X \to B$ be a continuous map with $f(x_0)=b_0$ and $X$ is connected. Suppose $g_1,g_2: X \to E$ are two continuous maps such that $p \circ g_1= p \circ g_2 = f$ and $g_1(x_0)=g_2(x_0)=e_0$, Then $g_1=g_2$.

For proving this theorem, my teacher first considered a set $S=\{x \in X |g_1(x)=g_2(x)\}$. The theme of proof was showing $S$ to be both open and closed in $X$ and then using connectedness of $X$ to show that $S=X$.
Now, the part of proof I am not able to understand is proving that $S$ is open. It is as follows:

Fix $x_1 \in X$ arbitrarily. Let $V_{f(x_1)}$ be any evenly covered neighbourhood of $f(x_1)$. Since $f$ is continuous, there exists a neighbourhood $W_1$ of $x_1$ such that $f(W_1) \subseteq V_{f(x_1)}$.
  Put $e_1=g_1(x_1)=g_2(x_1) \in E$. Let $U$ be the slice over $V_{f(x_1)}$ containing $e_1$.
  Since $g_1,g_2$ are continuous, there exist open neighbourhoods $W_2,W_3$ of $x_1$ in $X$ such that $g_1(W_2) \subseteq U$ & $g_2(W_3) \subseteq U$.
  Let $W_0=W_1 \cap W_2 \cap W_3$.
  Now, since $p \circ g_1 = p \circ g_2 = f$, therefore $f(x)=p(g_1(x))=p(g_2(x)) \forall x \in W_0$ where $g_1(x),g_2(x) \in U \forall x \in W_0$.
  But $p|U: U \to V_{f(x_1)}$ is a bijection $\Rightarrow g_1(x)=g_2(x) \forall x \in W_0$. Hence $W_0 \subseteq S \Rightarrow S$ is open.

Last line of the proof i.e. getting $S$ to be open is clear to me. But how we get $g_1(x)=g_2(x) \forall x \in W_0$is not clear to me.
 A: As $p$ is a bijection in $U$, in particular is injective, so $p(a)=p(b)$ implies that $a=b$ in $U$. In particular, take $a=g_1(x)$ and $b=g_2(x)$.
Edit:
Pick $x_1\in X$. We want to see that $g_1(x_1)=g_2(x_1).$ Well, given this $x_1$ we can find an open set $W_0$ containing $x_1$ with the particular property that $f(x)=p(g_1(x))=p(g_2(x))$ for every $x\in W_0$. But moreover, we have chosen $W_0$ in such a way that $p$ in bijective (in particular, injective) when restricted to $g_1(W_0)$ and $g_2(W_0)$, which are both contained in $U$. Therefore, if we pick any $x\in W_0$, we have $g_1(x)=g_2(x)$ due to the injectivity of $p$. In particular, it works for $x=x_1$. If you now pick a different $x_2\neq x_1$, we follow the same process to find a possibly different $W_0'$ where to apply our hypothesis.
If you choose $x_1\neq x_2$, of course that you need not have $g_1(x_1)=g_2(x_2)$, for the very reason that a map usually takes different values at different points (unless it is constant). For a concrete example, pick $p:X\to X$ to be the identity on the connected space, say $\mathbb{R}$, and any map, say the inclusion $[0,1]\to \mathbb{R}$, playing the role of $g_i$.
