fixing file write after restart, so that old file is not overwritten.