I'm trying to read in a file from disk and parse its data into a nice format. However, the function is not returning anything. It returns an empty array. Why is this?
Note: I've been tinkering around with this and I've managed to simplify the previous 2 functions to just this one.
The function:
func openFile(_ fileName:String, _ fileType:String) -> [(Double, Double)] {
        let file = fileName + fileType //this is the file. we will write to and read from it
        var text2: String = ""
        if let dir = FileManager.default.urls(for: .downloadsDirectory, in: .userDomainMask).first {
            let path = dir.appendingPathComponent(file)
            //reading
            do {
                text2 = try String(contentsOf: path, encoding: String.Encoding.utf8)
            }
            catch {/* error handling here */}
        }
        var pairs = [(Double,Double)]()
        var words: [String] = []
        for line in (text2.components(separatedBy: "\n").dropFirst()){
            if line != "" {
                words = line.components(separatedBy: "\t")
                pairs.append((Double(words[0])!,Double(words[1])!))
            }
        }
        return pairs
    }
