Use 'with' statemet when writing scripts to file.