How to incrementally backup data & use most recent data

Hey, dunno if the title really explains this well; basically my problem is (and this is on a router which is why the flash issue)...

I have some data I want to store (it's really irelevant, i'm just counting the lines per file, basically a simple counter).
I could store this data in flash but I'm wary of writing to it more than I have to given it's wear limit.
Therefore I want to store this data in memory and back it up to flash every few days (ok, I could do better but it's a simple problem so I use a simple solution), and assume reboots may occur causing the tmp data to be irelevant.

Thing is, I also need to reference the latest version of the data, which I know at times will be that in flash, but before I back it up it'll be that in memory, and I'm not sure what the best way to go about checking is.

Example (and note only 2 events, causing 1 \n 2, ever occur, and i need to know this always):

A) Tmp file contents:
Perm backup file contents:

I run a backup script every couple days (if a reboot happens between then I'm not so bothered), so far just "cat tmp.file > perm.file.

2 events cause data to fill tmp.

B) Tmp file contents: 1 \n 2
Perm backup file contents:

Now if I reference these, I can just use whatever has the higher line count.

Now I backup. cat tmp.file > perm.file

C) Tmp file contents: 1 \n 2
Perm backup file contents: 1 \n 2

Time goes by. another backup. cat tmp.file > perm.file

D) Tmp file contents: 1 \n 2
Perm backup file contents: 1 \n 2

reboot happens.

E) Tmp file contents:
Perm backup file contents: 1 \n 2

at this point use of whatever has the higher line count is still fine. but on a backup using cat tmp.file > perm.file:

F) Tmp file contents:
Perm backup file contents:

Not good. So I try cat tmp.file >> perm.file

A) Tmp file contents:
Perm backup file contents:

B) Tmp file contents: 1 \n 2
Perm backup file contents:

C) Tmp file contents: 1 \n 2
Perm backup file contents: 1 \n 2

D) Tmp file contents: 1 \n 2
Perm backup file contents: 1 \n 2 \n 1 \n 2

E) Tmp file contents:
Perm backup file contents: 1 \n 2 \n 1 \n 2

F) Tmp file contents:
Perm backup file contents: 1 \n 2 \n 1 \n 2

So now even though 2 events only ever happened, perm has 4 recorded, and just checking for the file with most data to get correct stats from ain't gonna help.

So.... My solution so far is: cat tmp.file >> perm.file && > tmp.file (wipe tmp.file of any data).

A) Tmp file contents:
Perm backup file contents:

B) Tmp file contents: 1 \n 2
Perm backup file contents:

C) Tmp file contents:
Perm backup file contents: 1 \n 2

D) Tmp file contents:
Perm backup file contents: 1 \n 2

E) Tmp file contents:
Perm backup file contents: 1 \n 2

F) Tmp file contents:
Perm backup file contents: 1 \n 2

So far so good. But if another call happens at some point...

A) Tmp file contents:
Perm backup file contents:

2 events cause data to fill tmp.
B) Tmp file contents: 1 \n 2
Perm backup file contents:

backup. cat tmp.file >> perm.file && wipe tmp
C) Tmp file contents:
Perm backup file contents: 1 \n 2

another event. now there's been 3.
D) Tmp file contents: 3
Perm backup file contents: 1 \n 2

backup. cat tmp.file >> perm.file && wipe tmp
C) Tmp file contents:
Perm backup file contents: 1 \n 2 \n 3

So my best idea so far is cat x >> y && wipe x, and when checking for data just add the (line count of the) two files together as the contents of both files should always equal the total number of events.

I'd just like to know if I'm going about that completely the wrong way? Is there a better / more efficient way of doing the above, and anyone see any issues in doing it the latter way? Thanks.