It's better to do it this way. Start with the expression without reference to any basis
$$\hat{H} \vert{\psi}\rangle = E\vert \psi\rangle$$
Then bring in $\langle x|$
$$\langle x|\hat{H} \vert{\psi}\rangle =\langle x| E\vert \psi\rangle$$
You are correct in having $\langle x|\psi\rangle=\psi(x)$, so the right hand side with scalar $E$ easily becomes $E\psi(x)$
On the left hand side we exploit our completeness relation $$\langle x|\hat{H} \vert{\psi}\rangle = \int\langle x|\hat{H}|x'\rangle\langle x' \vert{\psi}\rangle\,\text dx'= \int\langle x|\hat{H}|x'\rangle\psi(x')\,\text dx'$$
Since $\hat H =\hat H(\hat X,\hat P)$, the matrix elements of $\hat H$ in the position basis are given as $$\langle x|\hat{H}|x'\rangle=\delta(x'-x)H\left(x',\frac{\text d}{\text dx'}\right)$$
Therefore, we end up with
$$\langle x|\hat{H} \vert{\psi}\rangle =H\psi(x)$$
And so we have $$H\psi(x)=E\psi(x)$$