opening a file for writing and reading