add writeFile method