Python menghitung kata dalam file

import re
# Open file in read mode
input_file = open("C:\\Users\\fawaz\\Desktop\\data.txt", "rt")
"""
Get each line from file
Then decompose it into words
Update count with nb of words
per line.
"""
count = 0
for line in input_file: 
	words = re.split("\s+", line.strip())  # words separated by any nb of white spaces
	print(words)
	count += len(words)

print("Number of words in input file:", count)

input_file.close()
Wissam