File gets overwritten: how to avoid

I am new to Digi WiMe and NetOS in general. I have declared two files on my FLASH as follows:
#define data_FILENAME “FLASH0/data.txt”
#define Ptrs_FILENAME “FLASH0/ptrs.txt”
and in customize.ldr I have:
so 2MB is reserved for FLASH file system!

I collect data from my serial port continuously and write it to the data_FILENAME. When 1 Mbyte of data is written I start writing from beginning of file again. Thus I am limiting my data file to 1MB. However after about say 600Kbytes of data, my data is getting written to the Ptrs_FILENAME by mistake. How do I avoid this? How to I ensure that memory is protected? How do I set different sections of memory for these two files so that they dont overwrite each other?

Thank you!

any help on this???