Use isAtEndOfLine() method instead of homemade