open file function