added write function in thread.php