fix file write issue