Warning: I'm new to coding and any constructive criticism is welcome
My goal: I'm trying to read and scrape a .txt for anything coming after a few specified characters (in this case it's '[CHAT] [@]'). Then I want to write that selected data to a new file.
This is purely for coding practice
with open("/Users/barge/Desktop/Untitled.txt", "r") as logsfile:
for line in logsfile:
if "[CHAT] [@]" in line:
print(line[44], end='')
with open("newtestfile.txt", "w+") as newfile:
for eline in newfile:
newfile.write(line[44])
logsfile.close()
newpyfile.close()
My issue: I'm not getting any errors in the terminal but my output file 'newtestfile.txt' is empty each time I run it. Line 7 should be writing all the characters after the 44th index of Untitled.txt right?
Thanks.