Use -1 instead of line.length