If $M\prec (L_{\omega_1},\in)$, then $M=L_\alpha$ for some $\alpha$. This is exercise 13.17 of Jech's Set Theory:

If $M\prec (L_{\omega_1},\in)$, then $M=L_\alpha$ for some $\alpha.$
  [Show that $M$ is transitive. Let $X\in M$. Let $f$ be the $<_L$-least mapping of $\omega$ onto $X$. Since $f$ is definable in $(L_{\omega_1},\in)$ from $X$, $f$ is in $M$. Hence $f(n)\in M$ for each $n$ and we get $X\subseteq M$.]

There are two things that I do not understand. 
First, $f$ is definable in $(L_{\omega_1},\in)$ from $X$ and $\omega$, so to show that $f\in M$, shouldn't we show first that $\omega\in M$?. 
Second, if $f\in M$, the only way I see to prove $f(n)\in M$ for each $n$ would be to show that $n\in M$ for all $n<\omega$, but I don't see why this is true, as I can't even tell that $\emptyset^M=\emptyset$. 
Any help is appreciated, thanks.

The general fact here is: If $M \prec N$ and $a$ is definable in $N$ from parameters that happen to belong to $M$, then $a$ is in $M$ itself.  This follow from the definition of elementary substructure and the definition of definability.  Recall:
$M \prec N$ iff $M\subset N$ and for any formula $\phi$ and tuple $\bar{p}$ of elements of $M$, $M\vDash\phi(\bar{p}) \Leftrightarrow N\vDash\phi(\bar{p})$.
$a$ is definable in $N$ from parameters $\bar{p}$ iff there exists a formula $\phi$ with free variables $x, \bar{y}$ such that $N\vDash \exists !x \phi(x,\bar{p})$ and $N\vDash \phi(a,\bar{p})$.
0, every finite number, and $\omega$ are all definable in $L_{\omega_1}$ from no parameters.
