Boundedness of continuous functions. I am trying to prove:
Suppose that  $f: \Bbb{R} \to \Bbb{R}$ is continuous on $\Bbb{R}$ and that 
$$\lim_{x \to \infty} f(x) = 0$$
and 
$$\lim_{x \to -\infty} f(x) = 0$$
Prove that f is bounded on $\Bbb{R}$
So far I have said $f:\Bbb{R} \to \Bbb{R}$ is continuous on $\Bbb{R}$ implies f is bounded on $\Bbb{R}$ and that there exists an $M$ such that, for all $x$ in $\Bbb{R}$, |f(x)| $\le$ $M$.
I achieved this by manipulating the definition I was given. I'm unsure if this proves boundedness or if I need to say more. 
Any help would be appreciated, thank you.
 A: It is not true that the fact that $f$ is continuous on $\mathbb{R}$ means that $f$ is bounded on $\mathbb{R}$.  Consider $f(x)=x$, for example.  However, a continuous function is bounded on any compact subset. 
The trick for this question is to divide $\mathbb{R}$ into three parts, and show that $f$ is bounded on each of them. 
For the first part, we use the fact that $\lim_{x\to \infty}f(x)=0$.  By definition, there must be some $N$ such that
$$\forall x>N\, \left(\vert f(x) \vert<1\right).$$
(This is the usual definition of a limit with $\epsilon=1$.) Thus, $f$ is bounded (by $-1$ and $1$) on $(N,\infty)$. 
Likewise, we can find an $M$ such that $f$ is bounded on $(-\infty,M)$. 
All that remains is the part of $\mathbb{R}$ between $M$ and $N$.  So, how can we show that $f$ is bounded on $[M,N]$?  
A: What you "said" so far is not true. That $f$ is continuous on $\mathbb R$ does not imply $f$ is bounded on $\mathbb R$.
Hint: Since $f$ is continuous, can you prove it is bounded on any closed interval $[a,b]$?
Hint 2: You must prove that $f$ is bounded. For that, you can use the continuity of $f$ and the limit of $f$. Try to write down (in an edit to your question) the exact definition of what it means for $f$ to have a limit as $x\to\infty$. 
A: Suppose $f$ were not bounded. Then there exists a sequence $(x_n)\subset\mathbb R$ with $\lim_{n\to\infty}|f(x_n)|=\infty$. If $(x_n)$ were unbounded, it had a divergent subsequence, $(x_{n_k})_k$ say, $|x_{n_k}|\to\infty$, and we had $\lim_{k\to\infty}|f(x_{n_k})|=\lim_{n\to\infty}|f(x_n)|=\infty$, contradicting your assumption $\lim_{x\to\infty}|f(x)|=0$. Hence $(x_n)$ is bounded. Thus, it has a convergent subsequence, $(x_{n_l})_l$, say, with limit $x\in\mathbb R$. By continuity, $\lim_{l\to\infty}|f(x_{n_l})|=|f(x)|<\infty$, but $\lim_{l\to\infty}|f(x_{n_l})|=\lim_{n\to\infty}|f(x_n)|=\infty$, a contradiction.
A: Let $\varepsilon >0$ be given. From $f(x) \rightarrow 0$ as $x \rightarrow \infty$ and as $x \rightarrow -\infty$, we know there exists $N$ s.t. for all $|x| \geq N$,
$$ |f(x)| \leq \varepsilon.$$ Since $f$ is continuous, by extreme value theorem, there exists $M$ s.t. for all $x \in [-N,N]$,
$$ |f(x)| \leq M.$$ Therefore, for all $x \in \mathbb{R}$,
$$ f(x) \leq \max(M,\varepsilon).$$
