#!/usr/bin/env python from __future__ import print_function import os import sys if sys.version[0] < '3': input = raw_input fname = '' while not os.path.isfile(fname): fname = os.path.abspath(input("Path to the file: ")) with open(fname, 'r') as f: for line in f.readlines(): if ('127.0.0.1' not in line) and ('Jan' in line or 'Feb' in line): print(line, end = '')