 		var testRecordEnd:Bool = false
 		var field:String = ""
 		var record:[String] = []
-        for current:Character in characterData.characters {
+        characterData.forEach { current in
 			if testEscaped && current != quoteCharacter {
 				testEscaped = false
 				quoted = false

    
    fileprivate func encode(record: [String]) -> String {
        let escapedRecord:[String] = record.map { (field) -> String in
            guard field.contains(quoteCharacter) else {
                return field
            }
            
            let escapedField = field.replacingOccurrences(of: quoteSequence, with: escapeSequence, options: NSString.CompareOptions.literal, range: nil)
            return quoteSequence + escapedField + quoteSequence
        }
        return escapedRecord.joined(separator: fieldDelimiterSequence)
    }
}


//  Copyright (c) 2014 Frank Vernon. All rights reserved.
//

import Foundation

fileprivate let fieldDelimiter:Character = ","
fileprivate let recordDelimiter:Character = "\r\n"
