         
         let nsArray = NSArray(array: array)
         
-        LOG.info("Writing \(nsArray.count) words to file: \(filePath)")
-        let wasSuccessful = nsArray.write(toFile: filePath, atomically: true)
-        
-        if wasSuccessful
-        {
-            LOG.info("Wrote \(nsArray.count) words to \(filePath)")
-        }
+        guard let jsonString = serializer.toJSON(object: nsArray)
         else
         {
-            LOG.warn("Could not save words to \(filePath)")
+            LOG.warn("Failed to convert array to JSON")
+            throw LexisPersistenceError.ConversionError
+        }
+        
+        LOG.info("Writing \(nsArray.count) words to JSON File: \(filePath)")
+        
+        do
+        {
+            try jsonString.write(toFile: filePath, atomically: true, encoding: .utf8)
+            LOG.info("Wrote words to JSON file")
+        }
+        catch
+        {
+            LOG.error("Failed to write JSON to file \(filePath) : \(error)")
+            throw LexisPersistenceError.IOError
         }
     }
     

    }
    
    
    
    func getAllWords() -> [LexisWord]
    {
        LOG.info("Reading words from file :\(filePath)")
        
        guard let array = NSArray(contentsOfFile: filePath)
        else
        {
            LOG.info("Words not found in file \(filePath)")


class FilePersistence: LexisPersistence
{
    private let filePath = NSHomeDirectory().appending("/Library/Caches/LexisWords.json")
    
    static let instance = FilePersistence()
    
    private let parallelism = 6
    private let async: OperationQueue
    private let serializer = BasicJSONSerializer.instance
    
    private init()
    {
