Add some comments
Handle messages that can't be converted
Write file in error state if text extraction fails
Implement writing error file