I don't think your working is correct, because I don't think you can assume the equality holds. Is k positive? If so, why not do this:
and so on. The end result is very like what you got, except that all the steps here are valid (I think), whereas, like I said, I don't think you can assume that the equality holds which gives you your differential equation.