Let $X= \bigcup X_n$ be a countable union of subsets $X_1\subset X_2\subset \dots$ and let $X$ and $Y$ be topological spaces. Given a function $f\colon X\to Y$ such that $f|_{X_n}$ is continuous, is it necessarily true, that $f$ is continuous on $X$?
I have been trying to think of a counter-example but could find one although it does not quite seem to be enough information on $f$ for it to be continuous. First of all I am interested in a proof or counter-example for this statement, but after all I am also looking for a maybe similar statement that is true.
Edit: If I understood both answers right, additionally assuming that all closures $\bar X_n= X$ would suffice for the assertion?