Bug fix in write with timeout.