So I have this problem: I want to delete a specific item from a .txt file but when I launch the file It just closes! If I have my code like this It just closes:
nc = input('Name:')
f = open("info.txt", "w")
for line in f:
if line != nc:
f.write(line)
But when I change my code like this:
nc = input('Name:')
f = open("info.txt", "w")
for line in f:
if line != nc: f.write(line)
It works until I get to the point of code when I`m deleting something and then just closes and deletes everything in the .txt file!
Someone, please help me!