I have a function that adds a date to the contents of the file 'completed.txt' every time I call on it and supply the date. The function is as below :
def completed(date):
try:
os.chdir(libspath)
os.system("touch completed.txt")
fileobject=open('completed.txt',"r+")
fileobject.write(date+' \n')
fileobject.close()
except:
print "record.completed(): Could not write contents to completed.txt"
where libspath is the path to the text file. Now when I call on it say completed('2000.02.16')
, it writes the date into the completed.txt file. When I try adding another date to it say completed('2000.03.18')
then it overwrites the previous date and only '2000.03.18' is now in the text file but I want both the dates to be available in the file to use it as a record