Doubt in basic structures

I have built a binary search tree with “temp” pointer at its root. The tree works fine, but I can’t seem to find the problem with this part. Please help me figure it out.

while(1){
		if(q>temp->data){
			//printf("abfa");
			temp=temp->right;                 ////   does not execute after this line.
			//printf("%d",temp->data);
		}
		else if(q<temp->data){
			printf("vfhav");
			temp=temp->left;
			printf("%d",temp->data);
		}
		else{
			preorder(temp);
			free(temp);
			break;
		}
	}```