Add method that writes program to file