title: Reading from txt file in Swift 3
body: <p>I want to know how to read from a txt file and print out specific parts of the file?</p>
  
  <p>For example, "test.txt" will contain:</p>
  
  <p>'''Jason 16 male self programing</p>
  
  <p>Josh 15 male friend art'''</p>
  
  <p>So I am looking for a way to print each word and line separately. Such as only printing:</p>
  
  <p>"Jason"</p>
  
  <p>"Jason is 16"</p>
  
  <p>"Josh likes art"</p>
  
  <p>This is what I got so far from searching around</p>
  
  <pre><code>if let filepath = Bundle.main.path(forResource: "test", ofType: "txt")
      {
          do
          {
              let contents = try String(contentsOfFile: filepath)
              print(contents[0])
  
          }
          catch
          {
              // contents could not be loaded
          }
      }
      else
      {
          // example.txt not found!
      }
  </code></pre>
  
  <p>Thank you for your support.</p>