TITLE: Where is the flaw in my proof that the union of two continuous functions is continuous?
QUESTION [14 upvotes]: Problem.
  Let $f:A\to\mathbb{R}$ be a continuous function on $A$ and $g:B\to\mathbb{R}$ be a continuous function on $B$ such that $A\cap B=\emptyset$. Let $h:A\cup B\to\mathbb{R}$ be defined by, $$h(x)=\begin{cases}f(x)& x\in A\\ g(x)& x\in B\end{cases}$$Is $h$ continuous on $A\cup B$?
Proof. Let $(x_n)_{n\ge1}$ be any sequence from $A\cup B$ converging to $c\in A\cup B$. Let us now form two subsequences of $(x_n)_{n\ge1}$, namely $(y_n)_{n\ge1}$ and $(z_n)_{n\ge1}$ such that $y_n\in A$ and $z_n\in B$ for all $n\in \mathbb{N}$. 
Then clearly $(h(y_n))_{n\ge1}\to h(c)$ since $h(y_n)=f(y_n)$ for all $n\in\mathbb{N}$ and $(h(z_n))_{n\ge1}\to h(c)$ since $h(z_n)=g(y_n)$ for all $n\in\mathbb{N}$. Consequently $(h(x_n))_{n\ge1}\to h(c)$ and we are done.

But the problem is that when I told our professor about this proof he told me that there should be some other conditions. But the argument seems to work well. Where is the flaw (if any) in my argument?

REPLY [2 votes]: Suppose there are two constant functions: $f: (-\infty,0] \to \{0\}$ and $g: (0, \infty) \to \{1\}$. Can you see where your reasoning fails?