This (and also missed error for except) because all this part was written as just proof-of-concept while I'm trying to understand you requirement about 'all code in one file' .