Created by: Andrej730
Description
Fixed typo and unclosed file. Moved all paths processing to pathlib more readability, added check that exporting path is a file and not a folder.
Preflight checklist
Put an x letter in each brackets when you're done this item:
- 
Code changes complete.  - 
Code documentation complete.  - 
Documentation for users complete (or not required, if user never sees these changes).  - 
Manual testing done.  - 
Unit-tests implemented.  - 
Ready for merge.