The writeAll() method refactored.