Well, in my case the file would only contain just one number.... if the file is empty it should just write 1 in the file.What if there's more than just a number in it? Like maybe you gave it your shopping list by mistake, instead of a scorecard?
At any rate, this is a surprisingly complicated problem, and the solution is probably specific to each use. So I think you're far more likely to get a set of individual tools that you can use to put your own solution together, instead of a complete solution already done.
- Take the first or last number?
- Replace the entire contents with just the result?
- Replace only the found number with its result?
- Increment all found numbers in-place? ( https://www.youtube.com/watch?v=bcGA4alhPas )
- Just fail?
- What should that failure do?
Thx for the reply.