Change API, add writeToFiles