Writes total in file