updated writeFile method signature
added some unit tests for