Replace write() with toFile() to allow streams in the future #30