#! /usr/local/bin/python import os import sys try: fi = open('sample_+_file', 'w') except IOError: print 'Can\'t open file for writing.' sys.exit(0)