I have a model $Y = f(X) + \epsilon$
where $\epsilon$ is independent of $X$ and $\mathbb{E}[\epsilon]=0, \mathbb{E}\left[\epsilon^2\right]=\sigma^2$.
Show that $$ f(X)=\mathbb{E}[Y \mid X] $$
This is my attempt at the proof:
$$ \begin{aligned} & E[Y \mid X] \\ &= E[f(X)+\varepsilon \mid X] \\ &= E[f(X) \mid X]+E[\varepsilon \mid X] \\ &= E[f(X) \mid X]+E[\varepsilon] \\ &= E[f(X) \mid X]+0 \\ &= E_{Y \mid X}[f(X) \mid X] \quad\quad\quad \quad \quad\ \ (5) \\ &= \sum_{y \mid x} f(X) P(Y|X=y| x) \quad\quad(6) \\ &= f(X) \sum_{y \mid x} P(Y|X=y| x) \quad\quad(7)\\ &= f(X) \end{aligned} $$
I am a bit iffy about steps (5) to (6) to (7), please help. Thank you!