#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
using namespace std;

int main() {

    stringstream myfile{"hello124\t4\nzxA23\n2\nz"};
    
    if (myfile) { //if file is open then
        int c; 
        while((c = myfile.get())!=EOF){ //while succesful read
                            //remove all chars, special and whitespace
            if (isdigit(c) || c=='\n') 
                cout.put(c); // then write the line in the output file 
        }
   }
    else{
        cout << "Error in opening file" << endl;
    }
        return 0;
}