Fix line num calculation in newchar

Fix PR #8613
Thank you.