Is the root file different if a custom rom is installed? Do I need a different root file if I have installed a custom rom on Android?
Who creates root files for devices?
basically root method is pretty generic. the leading tools are

Magisk
SuperSU
phh's SuperUser
AddonSU

in that the order, where former one is recommended for all devices and ROMs while the last is ROM specific
However, while the rooting process is nearly the same, every device is different and there is no generic root method. First you need to unlock bootloader. Some vendors (like Huawei) decided to lock devices completely, others (like Samsung, Xiaomi, Lenovo) have there own special protections
Second, you need custom recovery (or at least, modified boot.img) which is definitely device specific and not interchangeable with other device models
Usually every device has it's own section in famous xda forum where developers share custom recovery or custom rom
Always search for root method specific for your device model
(Note: i am aware of exploit based temp root methods but decided that is out of scope and not worth a timeless answer, because development is ongoing and that exploits become outdated)