Let $X$ be a metric space and $Y$ be a compact metric space. I want to show that the graph of $f$, $G\subset X\times Y$ is closed $\iff$ $f:X\to Y$ is continuous.
I'm not sure where the compactness of $Y$ comes into play. I think I've already proven $f$ continuous $\implies G$ closed without using compactness, so I think it's supposed to be used in the other direction. Here's my attempt at $G$ is closed $\implies f$ is continuous:
Let $(x_n)\subset X$ be a sequence such that $x_n\to x\in X$. Now consider the sequence $((x_n,f(x_n)))\subset G$. Since $G$ is closed, $L=\text{lim}(x_n,f(x_n))\in G$. But $L=(\text{lim} x_n,\text{lim} f(x_n))=(x,\text{lim} f(x_n))$. So for $L$ to be in $G$, we must have $\text{lim}f(x_n)=f(x)=f(\text{lim}x_n)$. So $f$ is continuous.
Is there something wrong with my solution? Where is compactness of $Y$ needed?