put in the file opening and writing functionality of the save function