The correct way to do it is to paint slightly over the edge of the timber by a couple of millimetres to create a seal but if you are not a skilled painter it’s hard to do this without making a mess of it.
Your carpenter’s method will achieve a satisfactory result but rather than using a razor blade I suggest using a proper window scraper such as this that uses Stanley knife blades.
So long as you keep the edge of the blade flat against the surface of the glass it won’t cause any scratches and, after a bit of practice, you should be able to get a professional result.