The following program can open a file and read the contents of the file line by line, it is worth mentioning that readline() reads line by line, while readlines() reads the entire file
f=open('G:\workspace\doc\name.txt','r')
line=f.readline()
while line:
print(line)
line=f.readline()
f.close()