fix blocking thread while a file is open

Fixes #20