'Write `data` to the secure temporary file. This method may be
called any number of times following instance initialization,
but after calling :meth:`read`, you cannot write to the file
again.'

def write(self, data):

    assert (self.last_action != 'read'), 'You    cannot    write    after    reading!'
    self.last_action = 'write'
    if isinstance(data, unicode):
        data = data.encode('utf-8')
    self.file.write(self.encryptor.encrypt(data))
