I am not sure why I am receiving this error. Everything in my program seems to be working perfectly. the program is basically a simple administration system to store username and password accounts.
the error i get is, ValueError: I/O operation on closed file.
the program successfully writes the first account, but the other accounts do not get stored in the .txt file
here is my code where i am getting the error
if savedata == 'y':
print ("\nData Successfuly Saved!")
filehandle = open(filename, "r+")
for username, password in store_data.items():
print(username, ":",password)
password = password.replace("\n","")
filehandle.write(username) # it says this line is my error
filehandle.write(":")
filehandle.write(password)
filehandle.write("\n")
filehandle.close()
else:
("Exiting Application Terminal...")