If f(x) is continuous and M(x) is the maximum value of f(x) in the closed interval [x,a], then prove that lim

Problem: 

If f(x) is continuous and M(x) is the maximum value of f(x) in the closed interval [x,a], then prove that
\lim_{x\to a^-}\,M(x)=f(a).

Answer: 

It is true that if f(x) is continuous and M(x) is the maximum value of f(x) in the closed interval [x,a], then \lim_{x\to a^-}\,M(x)=f(a).