fixed bug in fopen, all modes ignored and set to rwonly