Cleanup temporary file handling and text parsing