Fix #613.

Also improve line counting, in emacs 0 lines does not occur, maybe in
empty buffer.