the following code i am using to write to a file. i am not getting a file open error, but i am getting that the message authored no data in file. however before this function is called the same file was being read the same way to validate a pin number. and that works. whoever can help, please do?

Code:
int _WithDrawal(){
 float wd_amount;
 int fnd_type,fnd_pin;
 float balance;
 float rm_balance;
 char buf[BUFSIZ] = "Garbage", *fp, str_bal[20];
 int i=0;
 clrscr();
     gotoxy(15,1);
	printf("::Please Enter the amount you wish to withdraw::\n\n");
     gotoxy(25,3);
	printf("---------------------------\n");
     gotoxy(25,5);
	printf("===========================");

     gotoxy(28,4);
	  scanf("%f",&wd_amount);
	  getchar();
          getchar();

     if((ac_p=fopen("account_.txt","a"))==NULL){
		clrscr();
		gotoxy(25,10);
		printf("::Error occured while attempting to open accounts file::");
		getchar();
		getchar();
		clrscr();
		return 0;

     }
	if(fgets(buf, sizeof(buf), ac_p)==NULL){
                clrscr();
		printf("No Data in File");
		getchar();
		getchar();
                return 0;
         }

	  while(fgets(buf, sizeof(buf), ac_p)!=NULL)
		{
	  
                   if(i==0){fnd_type=atoi(buf);}	
		   if(i==3){fnd_pin=atoi(buf);}
		   if(i==4){balance=strtod(buf, &fp); i=-1;}

                   printf("Line %d: %s",i,buf);

		   i++;

		   if((fnd_pin==pin)&&(fnd_type==2)){
			puts("HALA");
                        getchar();

		      if(balance<wd_amount){
                    	printf("Amount requested not available");
		      }else{
			rm_balance = balance-wd_amount;
                        printf("%f",rm_balance);
			printf("%s",gcvt(rm_balance, 5, str_bal));
                        getchar();
		      }
                   }
                }
             
}