The problem: Let $S\subset \mathbb{R}$ be closed, and let $f\in L^1 ([0,1], m)$, where $m$ denotes the Lebesgue measure on $[0, 1]$. Assume that for all measurable $E\subset[0,1]$ with $m(E)>0$ we have $\frac{1}{m(E)}\int _E f(x) dx\in S$. Prove that $f(x)\in S$ for a.e. $x\in [0,1]$.
My progress: Currently I am trying to apply Lebesgue Differentiation Theorem (See Page 68 Theorem 6.10) to prove the statement. But I am not very confident about this because in that case, $m(E) \to 0$ and I feel I miss a part to explain why I can still apply Lebesgue Differentiation Theorem. Any comments are appreciated!
Let $ F=\{x\in [0,1]:f(x)\not\in S\}=f^{-1}([0,1]\setminus S).$ Then $S$ measurable. Since $G=[0,1]\setminus S$ open, then $G=\bigcup I_j$, $j\in J$ where $I_j$ are disjoint intervals, $J$ countable.
If $m(\{x\in[0,1]:f(x)\in G\})>0$, then $m(\{x\in[0,1]:f(x)\in I_{j_0}\})>0$, for some $j_0\in J$. But, if $I_{j_0}=(a,b),$ then $$ m(\{x\in[0,1]:f(x)\in I_{j_0}\})=\lim_{n\to\infty} m\Big(\Big\{x\in[0,1]:f(x)\in \Big(a+\frac1n,b-\frac1n\Big)\Big\}\Big). $$ Hence, for some $n_0\in\mathbb N$, $$ m\bigg(\bigg\{x\in[0,1]:f(x)\in \Big(a+\frac1n_0,b-\frac1n_0\Big)\bigg\}\bigg)>0 $$ In such case, if $E=\big\{x\in[0,1]:f(x)\in \big(a+\frac{1}{n_0}, b-\frac{1}{n_0}\big)\big\}$, then $$ \frac{1}{m(E)}\int_E f\in \Big[a+\frac1n_0,b-\frac1n_0\Big] $$ and $\big[a+\frac1{n_0},b-\frac1{n_0}\big]\cap S=\varnothing$.