title: Reading input in kotlin using generate sequence
body: <p>I'm a newbie in kotlin. </p>
  
  <p>I was running the below code to understand how BigDecimal works, but i'm missing something on how to safely exit from intellij terminal after entering the input. I always get <code>NumberFormatException</code> if i don't enter anything and press Enter key. How to quit safely and see the result. </p>
  
  <pre><code>import java.math.BigDecimal
  
  fun main(args: Array&lt;String&gt;) {
      val input = generateSequence { readLine() }
      println(input
          .map { it.toBigDecimal() }
          .fold(0.toBigDecimal()) { a, b -&gt; a + b })
  }
  </code></pre>
  
  <p>Source
  <a href="https://medium.com/@elizarov/floating-point-for-decimals-fc2861898455" rel="nofollow noreferrer">https://medium.com/@elizarov/floating-point-for-decimals-fc2861898455</a></p>