Does this proof fail if $H$ is not finitely generated? The following is from Abstract Algebra (Dummit & Foote):  
If $G$ is a finite group and $H$ is a subgroup of $G$ such that $H=\langle S\rangle$ for some $S\subseteq G$, then prove that $H\unlhd G$ iff $gSg^{-1}\subseteq H$ for all $g\in G$.  
When considering the proof, it seems that the condition that $G$ is finite is never explicitly used, although there is a part of the proof that might be ambiguous in cases where $H$ is not finitely generated:
Proof ($\Leftarrow$):  Suppose that $H\leq G$ and $H=\langle S\rangle$ for some $S\subseteq G$. Suppose also that  $gSg^{-1}\subseteq H$ for all $g\in G$. Let $g\in G$, $h\in H$. Then $h=a_1^{n_1}\cdot a_2^{n_2}\cdots a_k^{n_k}$ for some collection of $a_i\in S$. Here, we compute $ghg^{-1}$ and show by induction (or semantics) that $ghg^{-1}\in H$ by sneaking a $g^{-1}g$ in between each term: $$ghg^{-1}=g\cdot a_1^{n_1}\cdot a_2^{n_2}\cdots a_k^{n_k}\cdot g^{-1}=ga_1g^{-1}ga_1\cdots ga_ng^{-1}\in H$$
My question is, does this argument fail if $H$ is not finitely generated? Why does the author use "G is finite" in the hypothesis, and is this condition necessary? If the condition is necessary, can anyone think of a clever counterexample for the infinite case?
 A: Consider the set of elements $x \in G$, such that $gxg^{-1} \in H$ holds for any $g \in G$. This is a subgroup of $G$ (to be precise it is the intersection of pre-images of $H$ with respect to the conjugation with $g$ for all $g \in G$), which contains $S$ by assumption. Hence this subgroup contains $\langle S \rangle =H$. No need for $G$ to be finite or finitely generated.
A: Since the map $\varphi\colon G\to G$ defined by $\varphi(x)=gxg^{-1}$ is an automorphism of $G$, you have that
$$
\varphi(\langle S\rangle)=\langle \varphi(S)\rangle\tag{$*$}
$$
for any subset $S$ of $G$. In your case you know that $\varphi(S)\subseteq H$, so
$$
H\supseteq\langle \varphi(S)\rangle=\varphi(\langle S\rangle)
=\varphi(H)=gHg^{-1}
$$
Since this holds for all $g\in G$, normality is proved.
The proof of $(*)$ doesn't need $S$ to be finite (and $\varphi$ can be any homomorphism, actually). You can prove it using the fact is that an element of $\langle S\rangle$ can be represented as $s_1s_2\dots s_k$, for $s_i\in S$ or $s_i^{-1}\in S$. 
There's a more general technique, however. Let $f\colon G\to G'$ be a group homomorphism and $S$ a subset of $G$. The subgroup $\langle f(S)\rangle$ is the intersection of all subgroups of $G'$ containing $f(S)$. Since $f(\langle S\rangle)$ is a subgroup of $G'$ containing $f(S)$, we have $\langle f(S)\rangle\subseteq f(\langle S\rangle)$. Conversely, $f^{-1}(\langle f(S)\rangle)$ is a subgroup of $G$ containing $S$, so $\langle S\rangle\subseteq f^{-1}(\langle f(S)\rangle)$ which entails $f(\langle S\rangle)\subseteq \langle f(S)\rangle$.
Note that once you have proved the result in this form, the same argument will work for any algebraic structure, such as rings, vector spaces and so on.
