Update main.py

fixed bug with file writing