I've very recently migrated to Python 3.5. This code was working properly in Python 2.7: with open(fname, 'rb') as f: lines = [x.strip() for x in f.readlines()] for line in lines: tmp = line.strip().lower() if 'some-pattern' in tmp: continue # ... code But in 3.5, on the if 'some-pattern' in tmp: continue line, I get an error which says: TypeError: a bytes-like object is required, not 'str' I was