$f$ is a continous function over $X$ if and only if $G(f)$ is compact 
Given a function $f:X\to Y$ with $X, Y \subset \mathbb{R}$. We define the graph of $f$ as the set
   $$G(f)=\{(x,f(x)),x\in X\}$$ Show that if $X$ is compact then $f$ is a
  continous function over $X$ if and only if $G(f)$ is compact.

I proved the first implication, but I couldn't prove the second. For the second, I take $(x_{n}, f(x_{n})) \in G(f)$, so $(x_{n},f(x_{n}) \to (x,f(x))$ (we use a subsequence, if necessary). My ideia is show that $\lim f(x_{n}) = f(x)$, but I but I couldn't.
I've seen other demonstrations using results of General Topology, but I wanted to know how to do it using only properties of $\mathbb{R}$.
 A: Let $(x_n,f(x_n))_n\subseteq G(f)$ be a sequence and let $x_n\to x$. Since $f$ is continuous then $f(x_n)\to f(x)$. By assumption $X$ is compact thus it is closed implying $x\in X$. Therefore $(x,f(x))\in G(f)$. This shows $G(f)$ is closed. Since $f$ is a continuous function on a compact set $X$ then it attains its minimum and maximum therefore $f$ is bounded. This implies that $G(f)$ is bounded set since it can be inserted inside a certain open ball in $\mathbb{R}^2$ of finite diameter $d_{G(f)}=\max\{|f_{\max}-f_{\min}|, d(X)\}$. Note $d(X)<\infty$ since $X$ is compact hence bounded. Therefore we obtain finally that $G(f)$ is a closed and bounded subset of $\mathbb{R}^2$. By Heine-Borel theorem it follows that $G(f)$ is compact. Now suppose that $f$ is not continuous. Say at some point $a\in X$ then there exists some sequence $(x_n)_n\subseteq X$ such that $x_n\to a$ but $f(x_n)\not\to f(a)$ which implies $(x_n,f(x_n))\not\to (a,f(a))$. Hence $(a,f(a))\notin G(f)$ i.e. $G(f)$ is not a closed set and consequently it is not compact.  
