Update main.py

Added a read-only check and add write to existing permissions