Also, it's always a good idea to wrap file/io type operations in a try/catch block. This way, you can do things such as try to open a file to read, and if it's not there, catch the exception and create a new file. The other option is to use the 'if file exists' functionality, that way you can take care of instances where if used for soemthing such as a configuration file for a script and the file was accidentally erased, you can have a clause which will create a new file with some default settings. For instance, something like the following:
print "file exists"
self._output = open(self.filename, "a")
print "creating new"
self._output = open(self.filename, "w")
str2write = "Default settings in here."
This was taken from a file logger class I created, so you may not be able to use it line for line, but it should give you an idea as to how to react and handle cases where the file is not there and handling gracefully, instead of causing an unhandled exception.