i am using scala to find a particular word in a line and extract that row, for that the sample that i am using is having data 

```
MSH|^~\&|RQ|BIN|SMS|BIN|2019||ORU^R01|120330003918|J|2.2
PID|1|xxxxx|xxxx||TEST|Rooney|19761202|M|MR^^M^MR^MD^11|7|0371 HOES LANE^0371

```

**Below is my code**

```
object WordCount {
    def main(args: Array[String])
    {
        val textfile = sc.textFile("/user/cloudera/xxx/xxx")
        val word = textfile.filter(x => x.length >  0).map(_.split('|'))
        val keys = word.map(tuple => (tuple(0),tuple(5),(tuple(6)) ))
        val data =keys.map(x => x._1 + "," + x._2+ "," + x._3)
        val srch = data.filter(_.contains("PID")).map(tuple => (tuple(0),tuple(1),(tuple(2)) ))
        val show = srch.map(x => x._1 + "," + x._2+ "," + x._3)
        data.saveAsTextFile("/user/cloudera/xxxx/Sparktest")
    }
}

```

**Result i am getting:**

```
MSH,BIN,20121009151949
PID,TEST^PATIENT,Rooney

```

**Result Expected**

```
PID,TEST^PATIENT,Rooney

```

What is that i am missing. Please help