Hi Padhi,
Check the following SAP help document on Files; For writing file you should open the file in OUTPUT mode, check and correct that as per help document;
http://help.sap.com/saphelp_bw33/helpdata/en/fc/eb3c7f358411d1829f0000e829fbfe/content.htm
Hope this helps.
Regards,
Karthik