Although the first char of a line should never be DWC_RIGHT, it would be best to check that SCROLL_LEFT > 0 before doing this to avoid ever dereferencing targetLine[-1].