I have a Gui application from which i have to write a timestamp along with the image number, so i have a code like this:

MyCameraWindow::MyCameraWindow(QWidget *parent) : QWidget(parent) {

.......................
timestampFile = fopen ( "timestamps.txt", "w");
.......................
}

void timestamp (FILE *out, int nframe){

struct tm *tmp;
time_t t;

t = time (NULL);
tmp = localtime (&t);

fprintf (out, "%4d\t%02d.%02d.%04d %02d:%02d:%02d\n", nframe, tmp->tm_mday,
tmp->tm_mon+1, tmp->tm_year+1900, tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
}

void MyCameraWindow::timerEvent(QTimerEvent*) {

for (int i=0; i < cameraCount; i++) cvGrabFrame (camera[i]);

if (recordFlag == 1) timestamp(timestampFile, ++frameNo);
for (int i=0; i < cameraCount; i++){
................
}
}

The file is being created but nothing is written, i cannot figure why! ... can someone tell me how to write to a file in Gui application?