Opening file in correct mode.