Basically I have this code that copies lines that contain a specific word and writes them in another file.
with open("test.txt", encoding='latin1') as f:
with open("output.txt", "a") as f1:
for line in f:
if str("Hello") in line:
f1.write(str(line.encode('UTF-8')) + "\n")
So what I'm trying to do is copy lines from test.txt that contain "Hello" and paste them in output.txt. For example the output should look like this:
Hello There
He said Hello
But I have this error where each line will look like this: b'Hello There\n'
The reason I have + "\n" in the code, is because without it, the file will write them all in a single line.
Anyone know how to fix it? :(