Use O_RDWR for FileMode.readWrite and createTrunc in ThreadedFile. See #337.