The problem is that there seems to be no check for EOF.

This here works:
    
    
    import asyncdispatch, asyncfile, os
    
    proc main() {.async.} =
      var filename = "test.txt"
      var file = openAsync(filename, fmRead)
      let fileSize = file.getFileSize()
      while file.getFilePos() < fileSize:
        let line = await file.readLine()
        if line.len == 0: break
        echo line
      
      file.close()
    
    waitFor main()
    
    Run

Reply via email to