Help on reading/writing a file

Hello all,
I’m practicing reading and writing a text file, skipping one element in the file.
I’m not returning the txt file in the terminal. Instead, I return this error statement:

<_io.TextIOWrapper name='line.txt' mode='w' encoding='cp1252'>

I have the .txt file in question in the same folder in which I’m writing the code, so I don’t think that is the problem.
I assume that I’m not defining the data type of the text file correctly? But I’m not sure. The code is below.
Thank you

with open('line.txt', 'r') as txt:
    lst = txt.readlines()
with open('line.txt', 'w') as txt:
    count = 0
    for line in lst:
        if count == 4:
        count +=1

#incorrect? unnecessary?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.