fwrite file using pthread