title: How to async read from a file in Nim?
body: <p>I was following the book Nim in Action.</p>
  
  <p>In Chapter 3, there was an example like this:</p>
  
  <pre><code>import asyncdispatch, asyncfile
  
  proc readFiles() {.async.} =
      var file = openAsync("/tmp/hello.py", fmReadWrite)
      let data = await file.readAll()
      echo(data)
      await file.write("Hello!\n")
      file.close()
  
  waitFor readFiles()
  </code></pre>
  
  <p>The only change I've made to the example was replacing the file name with one that existed on my system.</p>
  
  <p>The code was supposed to output the content of the opened file and write "Hello!\n" to it.</p>
  
  <p>But when I ran it, the <code>readAll</code> always returned an empty string, which I verified by add <code>assert len(data) &gt; 0</code>.</p>
  
  <p>What can I change to do async read successfully?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>The version of my <code>nim</code> compiler is:</p>
  
  <pre><code>$ nim --version
  Nim Compiler Version 0.19.0 [MacOSX: amd64]
  Compiled at 2018-09-28
  Copyright (c) 2006-2018 by Andreas Rumpf
  
  active boot switches: -d:release -d:useLinenoise
  </code></pre>