using c api for file handling