title: Removing empty key from RDD
body: <p>I am reading a text file and implementing a word count example. The problem is I am getting an RDD with empty Key.</p>
  
  <p>Here is code:</p>
  
  <pre><code>val tokens = sc.textFile("test.txt").flatMap(line =&gt; line.split(",")).map(_.trim)
  
  val tableForFrequency = tokens.map(word =&gt; (word, 1))
    .reduceByKey((a, b) =&gt; a + b)
  
  tableForFrequency.saveAsTextFile("file.txt")
  </code></pre>
  
  <p>I am not sure why I am getting an empty and how do I remove it.</p>
  
  <p>Please note: I am a newbie in Scala/Spark and have already looked for related question before posting this one.</p>