Как исправить ошибку в блокировщике сайтов python?

Написал простой блокировщик сайтов на python. Всё работает корректно за исключением одного, я смог заблокировать сайт ВК, но вот обратно - никак. С другими сайтами таких проблем не возникло.

Вот код:

redirect = '127.0.0.1'
websites = []

def block():
    while True:
        site = input('Адрес сайта для блокировки: ')
        if site == 'выход':
            break
        websites.append(site)
        print(f'Сайт {site} заблокирован')
        print('После добавления всех сайтов введите "выход" чтобы выйти')
    with open(path_to_hosts, 'r+') as file:
        content = file.read()
        for site in websites:
            if site in content:
                pass
            else:
                file.write(f'{redirect} {site}\n')


def unblock():
    while True:
        site = input('Адрес сайта для разблокировки: ')
        if site == 'выход':
            break
        print(f'Сайт {site} разблокирован')
        print('После добавления всех сайтов введите "выход" чтобы выйти')
    with open(path_to_hosts, 'r+') as file:
        content = file.readline()
        file.seek(0)
        for line in content:
            if not any(site in line for site in websites):
                file.write(line)
        file.truncate()

while True:
    f = open(path_to_hosts, "r")
    print(f.read())
    choosing_action = input('1 - Заблокировать сайт/ы \n2 - Разблокировать сайт/ы\n')
    if choosing_action == '1' or choosing_action == '2':
        break
if choosing_action == '1':
    block()
else:
    unblock()

Ответы (0 шт):