Try something like this...
lastSize = 0
lastLineIndex = 0
while True:
wx.Yield()
fileSize = os.path.getsize(logPath)
if fileSize > lastSize:
lines = infile.readlines()
newLines = 0
for line in lines[lastLineIndex:]:
newLines += 1
print line.rstrip()
lastLineIndex += newLines
if "DBG-X: Returning 1" in line:
break
if "DBG-X: Returning 0" in line:
break
fileSize1 = fileSize
infile.seek(0)
The key bit is
for line in lines[lastLineIndex:]:
Where we skip the lines we've already seen. You can probably skip the newLines
variable and just do lastLineIndex += 1
but I've got an aversion to changing lastLineIndex
inside the for loop (a habit I've picked up to avoid issues in other languages)