I'm trying to make a tool to read and send (real-time) information from a log to my screen.
So far I've been able to read everything and send the information line by line and send them all to the screen, follow the code.
import time
count = 0
while True:
arquivo = ('LOG')
arq = open(arquivo, 'r')
texto = arq.readlines()
arq.close()
count += 1
print(texto[count])
time.sleep(5)
The problem is that the program may or may not take a long time to generate a new line in the log, and when it reaches the last line, the problem closes with the error.
print(texto[count])
IndexError: list index out of range
How would I make the program, waiting for the new line to be inserted into the log file?