Writes the data back to the file