# Open set in $\mathbb{R}$ is a union of at most countable collection of disjoint segments

Let $E$ be a closed set in $\mathbb{R}$.

Then $E^c$ is open, hence it is a union of at most countable collection of disjoint segments, $\{I_i\}$.

Say, $I_i=(a_i,b_i)$.

Now, suppose $x\in E$ and $x$ is not an interior point of $E$.

How do i prove that $x$ is an endpoint for some $I_i$?

-
You can't. See this related question. – arjafi Oct 23 '12 at 15:40

The simplest example I can come up with to show that this is not the case is the following: Let $$E = \left\{ \frac{-1}{n} : n \in \mathbb{N} \right\} \cup \{ 0 \} \cup \left\{ \frac{1}{n} : n \in \mathbb{N} \right\}.$$ Clearly $E$ is closed, and its complement is $$( - \infty , -1 ) \cup \bigcup_{n=1}^\infty \left( \frac{-1}{n} , \frac{-1}{n+1} \right) \cup \bigcup_{n=1}^\infty \left( \frac{1}{n+1} , \frac{1}{n} \right) \cup ( 1 , + \infty ).$$ However $0$ is not the endpoint of any of these intervals.
I have checked some solutions, but it all states that if $x\in E$, then $x$ is an interior point of $E$ or $x$ is an endpoint. math.ust.hk/~majhu/Math203/Rudin/Homework15.pdf – Katlus Oct 23 '12 at 16:33
@Katlus: I haven't gone through the details, but the only outstanding case is if the point $p$ is an accumulation point of endpoints of the open intervals, and hence also of $E$ itself. You should then be able to use the fact that the original function $f$ is continuous on $E$ together with the fact that $g$ is linear on the open intervals $(a_i , b_i)$ to show that $g$ is continuous at $p$. – arjafi Oct 23 '12 at 18:44