 for line in lines {
     //    ok = false
     if !(line.hasPrefix("#") || line.hasPrefix(" ")) {
-        let aLine = line.componentsSeparatedByString("\t")
+        let aLine = line.components(separatedBy: "\t")
         if aLine.count > 1 {
-
+            
             if let groupNum = groupNumbers[aLine[0]] {
                 let url = aLine[1]
-                var (source, githubName) = deriveSource(url)
+                var (source, githubName) = deriveSource(url: url)
                 // TODO: Check for trailing / and http vs https
                 if let exists = allUrls[url] {
                     print("Error: Duplicate URL: \(url)")


func readLines(filePath: String) -> [String] {
    //    var stream:NSStream = NSStream

    var allLines:[String] = []

    if let fileManager =  NSFileManager.defaultManager() as NSFileManager! {
        let fileExists = fileManager.fileExistsAtPath(filePath)
        if fileExists {
            let data:NSData? = fileManager.contentsAtPath(filePath)

            let aString = NSString(data: data!, encoding: NSUTF8StringEncoding)

            let str1:String = aString as! String
            allLines = str1.componentsSeparatedByString("\n")

        } else {
            print("file not found: \(filePath)")
        }


    }
    return allLines

}

func writeGoVar(groupNum: Int, url: String, name: String,
    source: String, githubName:String,
    tags: String, image: String, date: Int,
     isPaywall: Int, apisUsed: String,
      recType: Int, key: Int) {
        var allTagStr = ""

        let lowerTitle = name.lowercaseString
        let tagList = tags.componentsSeparatedByString(":")
        for t in tagList {
            if t != "" {

                allTagStr += "\"\(t)\","
            }
      }
        print("{\(groupNum), \"\(url)\",\"\(name)\",\"\(lowerTitle)\" ,\"\(source)\", \"\(githubName)\", []string{\(allTagStr)}, \"\(image)\", \(date), \(isPaywall), \"\(apisUsed)\", \(recType), \(key)  },")
}

func deriveSource(url: String) -> (String, String) {

    var source = "n/a"
    var githubName = ""
    var F:[String] // Translated from Perl?
    let F0 = url.componentsSeparatedByString("//")
    let url0:String = F0[1]
    F = url0.componentsSeparatedByString("/")
    if url.rangeOfString("github.com") != nil {
        source = "github.com/" + F[1]
        // githubName = url0.stringByReplacingOccurrencesOfString("github.com/", withString: "", options: NSStringCompareOptions.LiteralSearch, range: nil)
        githubName = F.last!

    var apisUsed: String
    var recType: Int
    var key: Int
    
    init(id: Int, groupNum: Int, source: String, url: String, title: String, githubName: String, tags: String, image: String, date: Int, isPaywall: Int, apisUsed: String, recType: Int, key: Int) {
        
        self.id = id
        self.groupNum = groupNum
        self.source = source
