Suppose $X$ has a $\rm{Binomial}(n,p)$ distribution. Then its moment generating function is
\begin{align} M(t) &= \sum_{x=0}^x e^{xt}{n \choose x}p^x(1-p)^{n-x} \\ &=\sum_{x=0}^{n} {n \choose x}(pe^t)^x(1-p)^{n-x} \\ &=(pe^t+1-p)^n \end{align}
Can someone please explain how the sum is obtained from lines (2) to (3)?
Adding to @krngrvr09 's response:
Because Bernoulli is a special case of Binomial distribution, PMF of binomial distribution $$\binom{n}{k}p^k(1-p)^{n-k}$$ can be rewritten as $$\binom{1}{0}p^1(1-p)^{1-0}$$
Thus, we can get the following for each instance of $X$ for $X \sim Bin(n,p)$ and $X = \sum^n_{j=1}X_j$ $$ \begin{array} \mathbb{E}[e^{tX_j}] & = \sum^n_{k=0}e^{tk}\binom{1}{0}p^1(1-p)^{1-0} \\ & = (pe^t +1 -p)^1 \ \ \ \ \ \ \ \text{by Binomial Theorem}\\ \end{array} $$