bug fix on raw data file write