Open and close file.