String Compression testcase

My 3rd test case if failing

#include<bits/stdc++.h>
using namespace std;

int main() {

string s;
cin >> s;

int le=s.length();
string w="";
int count=1;
for(int i=0;i<le;i++){
    if(s[i]==s[i+1] && s[i+1]!='\0'){
        count++;
    }
    else if(s[i]!=s[i+1] && s[i+1]!='\0'){
        w+=s[i];
        char digit=count+'0';
        w+=digit;
        count=1;
    }
    if(s[i+1]=='\0'){
        w=w+s[i];
        char digit=count+'0';
        w+=digit;
    }
}

cout << w << endl;


return 0;

}

Plz send your code by saving on ide only.

Plz mark this doubt as resolved if you were able to solve after discussing on chat