Show that $E[\sum_{i=1}^{N}X_i] =E(N)E(X_1)$ 
Let $(X_n)$ be a sequence of random variables that are independent and identically distributed, with $EX_n < \infty$ and $EX_n^2 < \infty$. Let N be a random variable with range $R \subseteq \Bbb{N}$, independent of $(X_n)$, with $EN < \infty$ and $EN^2 < \infty$. Show that $E[\sum_{i=1}^{N}X_i] =E(N)E(X_1)$

So, I tried to calculate $E(\sum_{i=1}^{N}X_i|N)$. I think that it might be $E(X_1)N$, so, I tried to show that $E[t(N)\sum_{i=1}^{N}X_i]=E[NE(X_1)t(N)]$ for all t which are bounded and Borel-measurable, but I don't know how to calculate $E[t(N)\sum_{i=1}^{N}X_i]$. Any hint?

Let $S_n = X_1 + \cdots + X_n$. Since $N$ is a.s.-finite, it follows that
$$ S_N
= S_N \sum_{n=0}^{\infty} \mathbf{1}_{\{N = n\}}
= \sum_{n=0}^{\infty} S_N \mathbf{1}_{\{N = n\}}
= \sum_{n=0}^{\infty} S_n \mathbf{1}_{\{N = n\}}
\qquad \Bbb{P}\text{-a.s.} $$
(This really shows that $\Bbb{E}[S_N | N] = N \Bbb{E}[X_1]$, but we need to check integrability condition for this to make sense.) Now from a simple estimate
\begin{align*}
\sum_{n=0}^{\infty} \Bbb{E} \big[ |S_n \mathbf{1}_{\{N = n\}}| \big]
& \leq \sum_{n=0}^{\infty} \Bbb{E} \big[ (|X_1| + \cdots + |X_n|) \mathbf{1}_{\{N = n\}} \big] \\
&= \Bbb{E}[|X_1|] \sum_{n=0}^{\infty} n \Bbb{P}(N = n) \\
&= \Bbb{E}[|X_1|] \Bbb{E}[N]
< \infty,
\end{align*}
we know that $S_N$ is integrable and that we can safely apply the Fubini's theorem to have
$$ \Bbb{E}[S_N]
= \Bbb{E}\Bigg[ \sum_{n=0}^{\infty} S_n \mathbf{1}_{\{N = n\}} \Bigg]
= \sum_{n=0}^{\infty} \Bbb{E} \big[ S_n \mathbf{1}_{\{N = n\}} \big]
= \Bbb{E}[X_1] \sum_{n=0}^{\infty} n \Bbb{P}(N = n)
= \Bbb{E}[X_1]\Bbb{E}[N]. $$
