Fix line num calculation in newchar

Fix PR #8613