I am having an issue with a timetracker program, where I am trying to identify a line in a file by iterating over it and then writing the lines UNLESS there is anything with the variable "delete" in it, for some reason its going through the file and saying it is deleted, but the loop doesn't delete any lines.
date = input(" What is today's date? month-day-year format please. (E.G. 01-14-2003) ")
if os.path.exists(date):
today = open(date, "r")
print(today.read())
delete = input(" Which appointment would you like to delete? (Please type the time E.G. 7:00) ")
#Open the file, save the read to a variable, iterate over the file, check to see if the time is what user entered, if it is not then write it to the line, close the file.
fileEdit = open(date, "r+")
for line in today.readline():
print(line)
if delete not in line:
fileEdit.write(line)
print(fileEdit.read())
today.close()
fileEdit.close()
print ("Appointment deleted, goodbye")