         return strippedLine
     }
     
-    func stringByAlteringCodeFencing(string: String) -> String {
+    func stringByAlteringCodeFencing(string: String) throws -> String {
         let outputText: String
         
         // Add a newline between the markdown delimiter if necessary
-        if string.matchesPattern("\\n", options: nil, error: nil) || count(string) == 0 {
+        if try string.matchesPattern("\\n", options: []) || (string as NSString).length == 0 {
             // Empty line
             outputText = "\n" + MarkdownCodeStartDelimiter + string
         } else {

        return output
    }
    
    func matchesPattern(let pattern: String, let options: NSRegularExpressionOptions, error: NSErrorPointer) -> Bool {
        let range = NSMakeRange(0, count(self))
        let regex = NSRegularExpression(pattern: pattern, options: options, error: error)
        let matches = regex?.firstMatchInString(self, options: nil, range: range)
        
        if matches == nil {
            return false

        }
        
        // Read data chunks from file until a line delimiter is found:
        var range = buffer.rangeOfData(delimData, options: [], range: NSMakeRange(0, buffer.length))
        while range.location == NSNotFound {
            let tmpData = fileHandle.readDataOfLength(chunkSize)
            if tmpData.length == 0 {
                // EOF or read error.
                atEof = true
