Fix line num calculation in newchar

Fix PR #8613
Just a note, but this line can be shortened even further to:
```c++
for (auto &iter : traits) {
```