added a thread in client to write the file to disk