Reduce handle count if writeFile() Throws. Mock fs module better for tests.