error with ret value of WriteDataToFile has corrected