How can I make a class for writing to Log text file.

I need to Initialize it in the beginning of the program and close it.

every time I call the Write sub of the class I need to open and close it...

not open it in the beginning and close it in the end.