#- Write a Python program that takes a text file as input and returns the number of words of a given text file.

#since the text file is auto generated by us so total lines will be total words typed by us plus the number of lines due to line file.write("\n")
file=open("sample_file","a")
while True:
    string=input("Enter the text:  ")
    file.write(string)
    file.write("\n")
    print("If want another line then press y else any key")
    text=input()
    if text!='y':
        break
file.close()
file=open("sample_file","r")
ans=0
for each in file:
    lenghth=len(each)
    ans+=lenghth
    print(each)
print("Total words are ",ans)
file.close()