This is the code I use to count lines in a file. I don't think it is wrong. But why the result is always one line more than I check directly using gedit ? I can just minus 1 to get the right result but I want to know why.
file = open(filename)
allLines = file.read()
file.close()
Lines=allLines.split('\n')
lineCount = len(Lines)