don't use writeFileSync.  instead make save accept a callback