title: Swift get user input with prompt
body: <p>In Swift, I want to have a continous user-input loop, much like how the python interpreter works, where a prompt is made, you type a line, the result of the line is displayed, and then the user is prompted again. This is my code so far:</p>
  
  <pre><code>import Foundation
  
  func input() -&gt; String {
      var keyboard = NSFileHandle.fileHandleWithStandardInput()
      var inputData = keyboard.availableData
      return NSString(data: inputData, encoding: NSUTF8StringEncoding) as! String
  }
  while true {
      println("Obl&gt;")
      var theInput = input()
      println("\(theInput)")
  
  }
  </code></pre>
  
  <p>However, this results in a scheme like this:</p>
  
  <pre><code>Obl&gt;
  hello world
  hello world
  Obl&gt;
  yo
  yo
  </code></pre>
  
  <p>What I want it to look like is this:</p>
  
  <pre><code>Obl&gt; hello world
  hello world
  Obl&gt; hello
  hello
  </code></pre>
  
  <p>How can this be accomplished?</p>