         guard let url = logFileURL, fileManager.fileExists(atPath: url.path) == true else { return true }
         do {
             try fileManager.removeItem(at: url)
-            fileHandle = nil
             return true
         } catch {
             print("SwiftyBeaver File Destination could not remove file \(url).")

        return formattedString
    }

    deinit {
        // close file handle if set
        if let fileHandle = fileHandle {
            fileHandle.closeFile()
        }
    }

    /// appends a string as line to a file.
    /// returns boolean about success
    func saveToFile(str: String) -> Bool {
        guard let url = logFileURL else { return false }
        do {
            if fileManager.fileExists(atPath: url.path) == false {
                

                    try fileManager.setAttributes(attributes, ofItemAtPath: url.path)
                }
                #endif
            }
            write(data: data, to: url)

            return true
        } catch {
            print("SwiftyBeaver File Destination could not write to file \(url).")
            return false
        }
    }

    private func write(data: Data, to url: URL) {
        let coordinator = NSFileCoordinator(filePresenter: nil)
        var error: NSError?
        coordinator.coordinate(writingItemAt: url, error: &error) { url in
            do {
                let fileHandle = try FileHandle(forWritingTo: url)
                fileHandle.seekToEndOfFile()
                fileHandle.write(data)
                if syncAfterEachWrite {
                    fileHandle.synchronizeFile()
                }
                fileHandle.closeFile()
            } catch {
                print("SwiftyBeaver File Destination could not write to file \(url).")
                return
            }
        }

        if let error = error {
            print("Failed writing file with error: \(String(describing: error))")
        }
    }

