Open file to read or write