# A linear subspace $Y$ is dense iff there is no trivial funcitonal vanishing on $Y$

So I was reading Conway's book "A course in functional analysis" and stumbled upon the following corollary of the Hahn-Banach separation theorem:

If $X$ is a locally convex space and $Y$ is a linear subspace of $X$, then $Y$ is dense in $X$ iff the only continuous linear functional on $X$ that vanishes on $Y$ is identical to the zero functional.

I do not quite understand, how you can draw this conclusion from the Hahn Banach theorems. I can see that the direction from left to right is rather trivial. However, when trying to prove the other direction I am getting a bit stuck:

Assuming $\overline{\ Y} \ne X$, I would get the existence of an $f \in X'$ and a $\gamma \in \mathbb{R}$, such that for a point $x \in \overline{\ Y} \backslash X$, and for all $y \in \overline{\ Y}$ we have $$\Re(f(y)) \le \gamma < \Re(f(x))$$ So I would get one random functional that separates $x$ from all the $y$. However, this $f$ does not have to be equal to zero on $Y$, hence my confusion. I am sure one can easily fix this, but I am not seeing it right now.

Any help would be greatly appreciated.

If $\overline Y\neq X$, take $x\in X\setminus Y$ and consider the functional $\gamma\colon\overline Y\oplus\mathbb{R}x\longrightarrow\mathbb R$ defined by $\gamma(y+tx)=x$. It is continuous and it vanishes on $\overline Y$. Now, extend it to a continuous linear functional from $X$ to $\mathbb R$.