fix a reference bug that data file could not be removed after message has been sent