this way everytime you need to ouput something into the file you open it, store the information, then close the file. this way you can have every file of source code store information into the file without having to worry that another peice of code has access to that file. to be double sure always include this before trying to store to a file
errorCondition = true;
you really can do anything if the oppening fails i just put this in as an example.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...