Scottish Water has been fined after it accidentally polluted a river, killing nearly 5,000 fish.