util: writeFileSync with chained conditionals