Chewbacca and Number

#include
using namespace std;
int main() {
string str;
cin>>str;
int i=0;
while(str[i]==‘9’){
i++;
}
for(;str[i]!=’\0’;i++){
int digit = 9-str[i]+‘0’;
if(digit<5){
str[i]=digit+‘0’;
}
}
cout<<str;
return 0;
}

One test case is showing wrong answer…
Please help!

Disha, pls use if(str[i]==‘9’) instead of while…and then try to submit