NZEC No such element exception; BST

Hello

Can somebody tell me what the issue with my code is. I am getting a No such Element Exception on Scanner.

public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner in = new Scanner(System.in);
int noOfQueries = in.nextInt();
Node root = null;
Node previous = root;
Node current = root;

	for (int i=1;i<=noOfQueries;i++) {
		String operation = in.next();
		int number = in.nextInt();
		if (operation.charAt(0) == 'i') {
			if (root == null) {
				root = new Node();
				root.setPosition(1);
				insertRootNode(number, root);
			} else {
				previous = root;
				current = root;
				insertNode(number, current, previous);
			}

// printTree(root);
} else {
deleteNode(number, root);
// printTree(root);
}
}
in.close();
}
}