Renamed DebugMsg, added function to write messages to file