fname = input('Podaj nazwę pliku: ') fhand = open(fname) count = 0 for line in fhand: if line.startswith('Subject:'): count = count + 1 print('Mamy', count, 'linii z tematem wiadomości w pliku', fname)