title: How to write contents of RDD onto S3?
body: <p>I have an RDD containing vertex id and it's x,y coordinates, I want to write its contents to a text file, on my local machine I'm doing that using a function </p>
  
  <pre><code>  def printVertices(iterable: Iterable[Vertex], filename: String): Unit = {
      val pw = new PrintWriter(new File(filename))
      for (point &lt;- iterable) {
        pw.write(point.id + ", " + point.coordinate.x + ", " + point.coordinate.y + "\n")
      }
      pw.close()
    }
  
  printVertices(dt.points.collect, s"$output/points$id.txt")
  </code></pre>
  
  <p>In the above code dt.points is an RDD, I want to save it to a text file if I do RDD.saveAsTextFile it writes the whole RDD, so I want to use my method and write to s3.</p>