             print(message)
             return
         }
-        let fm = FileManager.default
-        if !fm.fileExists(atPath: valid_logFilePath) {
-            do {
-                try "".write(toFile: valid_logFilePath, atomically: true, encoding: String.Encoding.utf8)
-            }
-            catch {
-                print("error:\(error)")
-            }
-        }
-        guard fm.isWritableFile(atPath: valid_logFilePath) else {
-            return
-        }
-        guard let valid_fileHandle = FileHandle(forWritingAtPath: valid_logFilePath) else {
-            let message: String = "Unable to obtain valid \(String(describing: FileHandle.self)) object!"
-            print(message)
-            return
-        }
-        let stringToWrite = "\(candidate)\n"
-        valid_fileHandle.seekToEndOfFile()
-        
-        guard let valid_data: Data = stringToWrite.data(using: String.Encoding.utf8) else {
-            let message: String = "Unable to obtain valid \(String(describing: Data.self)) object from candidate=\(stringToWrite)!"
-            print(message)
-            return
-        }
-        valid_fileHandle.write(valid_data)
-        valid_fileHandle.closeFile()
-        
+        WriterUtils.write(candidate, toFileAtPath: valid_logFilePath)
         SingleFileLogWriterImpl.cleanUpIfNeeded()
     }
     
-    fileprivate static func createLogsDirecotry(at path: String) {
+    fileprivate static func createLogsDirectory(at path: String) {
         guard !SingleFileLogWriterImpl.didCreateLogsDirectory else {
             return
         }
-        
-        let fm: FileManager = FileManager.default
-        if !fm.fileExists(atPath: path) {
-            do {
-                try fm.createDirectory(atPath: path, withIntermediateDirectories: false, attributes: nil)
-                SingleFileLogWriterImpl.didCreateLogsDirectory = true
-            }
-            catch {
-                print("error:\(error)")
-            }
-        }
-        else {
-            SingleFileLogWriterImpl.didCreateLogsDirectory = true
-        }
+        self.didCreateLogsDirectory = WriterUtils.createDirectory(at: path)
     }
     
     fileprivate static func logFilePath() -> String? {

    
    // MARK: - Utils
    static func currentDirectoryPath(from candidate: String) -> String? {
        guard let valid_url = URL(string: candidate) else {
            return nil
        }
        let pathComponents: [String] = valid_url.pathComponents
        let folderPath: String
        let fm = FileManager.default
        if fm.fileExists(atPath: valid_url.absoluteString) {
            folderPath = "/\(pathComponents[1..<pathComponents.count-1].joined(separator: "/"))"
        }
        else {
            folderPath = "/\(pathComponents[1..<pathComponents.count].joined(separator: "/"))"
        }
        return folderPath
    }
    
    static func writeToFile(_ candidate: String) {

        guard let valid_logFilePath: String = SingleFileLogWriterImpl.logFilePath() else {
            return
        }
        guard SingleFileLogWriterImpl.logFileMaxSizeInBytes > 0 else {
            return
        }
        let fileSize: UInt64 = SingleFileLogWriterImpl.fileSize(at: valid_logFilePath)
        guard fileSize > SingleFileLogWriterImpl.logFileMaxSizeInBytes else {
            return
        }
        WriterUtils.removeFile(at: valid_logFilePath)
    }
    
    fileprivate static func fileSize(at path: String) -> UInt64 {
        return WriterUtils.fileSize(at: path)
    }
}

