Fixed incorrect _write function