added support for all fopen modes