fix algorithm to convert character map into line number in CLI tool