file handling function in c