Set file mode when opening file