import os filepath = "Z:/10030530 Borssele III&IV_SBP/21 NHP/21 Survey Online/01 [100XXXXX - Online Project]/LogFiles/BLACKBOX Borssele III IV SBP.txt" with open(filepath, 'rb') as f: f.seek(-2, os.SEEK_END) while f.read(1) != b'\n': f.seek(-2, os.SEEK_CUR) print(f.readline().decode())