Fix line num calculation in newchar

Fix PR #8613
Why?
I don't know c++ so good. :/