added tools::writeToFile, untested