def main():
    try:
        with open('test.txt', 'w') as file:
            file.write("Plik testowy")
    except IOError as e:
        print("Błąd zapisu pliku:", e)
    except Exception as e:
        print("Inny błąd:", e)
    else:
        print("Plik zapisany pomyślnie")

if __name__ == '__main__':
    main()