Why could we conclude from $\sin\left(\frac{2 \pi n a}{b-a}\right)\neq0$ that the value of $k$ is incorrect? On the contrary, I think the conclusion is partly correct.In In fact, We can rewrite $A\sin(k x)+B\cos(k x)=C\sin(k x + \delta)$ to simplify the boundary condition. Thus it is evident that $ k= \frac{n \pi}{b-a}$.