Not sure exactly why this statement from a (real analysis) textbook is true:
Let $f:[0,+\infty)\to\mathbb{R}$ be continuous and let $\lim_{x\to+\infty}f(x)=L\in\mathbb{R}$. Then $f$ either attains maximum* or $\sup_{x\in[0;+\infty)}f(x)=L$.
*: Equivalent to saying there exists $y\in[0,+\infty)$ such that $f(y) = \sup_{x\in[0;+\infty)} f(x) = \max_{x\in[0,+\infty)}f(x)$.
What would the proof for this statement look like? The extreme value theorem doesn't apply since the interval isn't bounded. It's not entirely clear to me why it is true for examples like f(x) = 1/x. Any insight is appreciated!
Hint :
Prove that $f$ is bounded on $[0,+\infty)$. Deduce that $f$ has a finite supremum over $[0, +\infty)$.
If $f$ does not attains its supremum, show that the supremum has to be the limit $L$.