Popcorn function I need to construct a function whose set of points of discontinuities is a given
F-sigma set.
At the Follow-Up section of Wikipedia's article on the popcorn function, they give an example of such a function.
I just don't see why would we need closedness of the sets in the proof.
Could somebody briefly explain the proof?
Thanks

It’s convenient to assume that the closed sets $F_n$ are increasing, so that $F_1 \subseteq F_2 \subseteq F_3 \subseteq \dots$. This is a harmless assumption, since the union of any finite number of closed sets is closed: just replace $F_n$ by $\bigcup_{i=1}^n F_i$. Now we have $A = \bigcup_{n=1}^\infty F_n$, and we define the function $$f_A(x) = \begin{cases}
\frac1n,&\text{ if }x\text{ is rational and }n\text{ is minimal so that }x\in F_n\\
\frac{-1}{n}&\text{ if }x\text{ is irrational and }n\text{ is minimal so that }x\in F_n\\
0,&\text{ if }x \notin A.
\end{cases}$$
First we show that $f_A$ is continuous at each point of $\mathbb{R}\setminus A$. Suppose that $x \in \mathbb{R}\setminus A$; clearly $f_A(x)=0$. If $x$ has a nbhd $V$ disjoint from $A$, then $f_A(y)=0$ for every $y \in V$, so $f_A$ is certainly continuous at $x$. Assume now that $x$ has no such nbhd, so that every nbhd of $x$ meets $A$. 
For $n \in \mathbb{Z}^+$ let $V_n = \mathbb{R}\setminus F_n$; each $V_n$ is a nbhd of $x$. Suppose that $y \in V_m$ for some $m$. If $y \notin A$, then $f_A(y) = 0$. Otherwise, $f_A(y) = \pm 1/n$, where $n$ is minimal with $y \in F_n$. Since $y \in V_m$, $y \notin F_m$; and since the $F_i$ are nested, $y \notin F_i$ for any $i \le m$. Thus, $n>m$. This shows that $$\vert f_A(y)\vert < \frac1m$$ for every $y \in V_m$. In other words, given any $\epsilon > 0$, we can choose a positive integer $m$ such that $1/m < \epsilon$, and $V_m$ will be a nbhd of $x$ such that $\vert f_A(y)-f_A(x)\vert < \epsilon$ for every $y \in V_m$. This of course means that $f_A$ is continuous at $x$.
It remains to show that $f_A$ is discontinuous at each point of $A$. Fix $x\in A$, and assume that $x$ is rational. (The argument for irrational $x$ is almost identical.) Then $f_A(x) = 1/n$ for some $n \in \mathbb{Z}^+$, and we have to consider two possibilities. First, it may happen that $x$ has a nbhd $V\subseteq F_n$. If $n>1$, we may further assume that $V \subseteq V_{n-1}$, since $x$ is not in the closed set $F_{n-1}$. (Here I’m using the fact that $F_{n-1}$ is closed.) Let $W$ be any nbhd of $x$; then $W\cap V$ is a nbhd of $x$, so it contains some irrational $y$. But $W \cap V \subseteq F_n$, so $y\in F_n$; moreover, $y\in V_{n-1}$ if $n>1$, so $f_A(y) = -1/n$. Thus, each nbhd of $x$ contains a point $y$ such that $$\vert f_A(y)-f_A(x)\vert = \left\vert\frac1n-\frac{-1}n\right\vert=\frac2n,$$ and $f_A$ must be discontinuous at $x$.
The other possibility is that no nbhd of $x$ is contained in $F_n$. Then if $V$ is a nbhd of $x$, $V\cap V_n \ne \varnothing$. Let $y \in V\cap V_n$ be irrational. (Here again I’m using the fact that $F_n$ is closed: I need to know that $V\cap V_n$ is open in order to be sure that it contains an irrational.) If $y\in A$, $f_A(y)<0$, and if $y\in \mathbb{R}\setminus A$, $f_A(y)=0$, so in any case $f_A(y)\le 0$. But then $$\vert f_A(y)-f_A(x)\vert = f_A(x)-f_A(y) \ge f_A(x) = \frac1n,$$ so again $f_A$ must be discontinuous at $x$.
