counter = 0 print('file: sample.txt') print('#' * 60) with open('sample.txt', mode='r') as f: for line in f.readlines(): counter += 1 print(line.strip()) print('#' * 60) print('end file') print('Количество строк в sample.txt is', counter)