Are you making sure to set all things that should be set to NULL are set to NULL at the end of the function? Have you checked for memory leaks? Are you opening, writing and then closing the file each time, or are you leaving the file open for subsequent writes? If you post your codes we would have a better chance to locate any problems.
wabbit
"The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
Edsgar W. Dijkstra
MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK
For custom MetaStock programming : http://www.wabbit.com.au
My SkyPE status : 
My SkyPE account : wabbit.com.au