Write into text file in wxpython

Hi, how do we write value into text file in wxpython. As in python, file_out = open("filename", "wb") is used (as far as I know). Im trying to write the value from textctrl using:

self.val = self.textctrl.GetValue()

So, as for the next step to write the value into text file, is it possible? If yes, how?

Any help is appreciated!