Every railroad company operating its line of road, or any part thereof, within this state shall be liable for all damages by fires that are set out or caused by operating any such line of road, or any part thereof, in this state, whether negligently or otherwise. Such damages may be recovered by the party damaged by a proper action in any court of competent jurisdiction; but said action shall be brought by the party injured within two years next ensuing after it accrues. The liability imposed in this section shall inure solely in favor of the owner or mortgagee of the property so damaged or destroyed by fire, and the same shall not pass by assignment or subrogation to any insurance company that has written a policy thereon.