Open file in writing and reading modes