open function for file handles