title: Fatal error: glibc detected an invalid stdio handle when using kotlin-native
body: <p>I was playing around with kotlin-native, trying to open a file. The file is opened and created correctly, however, when printing to the file I get the error "Fatal error: glibc detected an invalid stdio handle</p>
  
  <p>Process finished with exit code 134 (interrupted by signal 6: SIGABRT)"</p>
  
  <p>Am I doig something wrong here? Or is this a kotlin configuration issue? The same code does work in C</p>
  
  <pre><code>import kotlinx.cinterop.*
  import platform.posix.*
  
  fun main(args: Array&lt;String&gt;) {
      val home = getenv("HOME")?.toKString() ?: "NONE"
      val fopen: FILE = fopen("$home/checkinTime", "w")?.pointed ?: throw RuntimeException()
      val readValue: CValue&lt;FILE&gt; = fopen.readValue();
      fprintf(readValue,"String")
  }
  </code></pre>