Of course, we would need to see the content of the the "res.txt" file to ascertain that the above proposed solutions will work on it. (Or at least you should confirm that there is nothing else that "1+2" in your file. If not, then some additional preprocessing might be needed.)