Try using open() instead of fopen()