API here is a bit weird.  cb functions should pass err as their first argument.  Better to just call fs.writeFile with the supplied cb, than to force a throw.