Saving Console Messages

Saving console messages history on a .txt file in the main folder.
This is a very basic version, i would be pleased if somebody 'refine' that.