Plaintiff Cambridge Mutual Fire Insurance Company (Cambridge Mutual) appeals an order of the Superior Court (Fitzgerald, J.) granting defendant Thomas Crete’s motion to dismiss its subrogation action. Plaintiffs Merle and Tammy Wilbur appeal an order of the Superior Court (Fitzgerald, J.) dismissing their action alleging that Crete is liable for fire damages to their uninsured property. All plaintiffs appeal the superior court’s denial of their motions to amend the writ. We affirm in part, vacate in part and remand.
The plaintiffs allege the following facts. The Wilburs own a residential dwelling in which Crete leased an apartment in 1999. Cambridge Mutual insured the Wilburs’ building against fire damage.
On October 25,1999, a fire caused extensive damage to the building. An investigation revealed that the fire originated on a mattress in Crete’s bedroom. Crete is a cigarette smoker and was the last person in the building before the fire. Cambridge Mutual reimbursed the Wilburs for their covered losses, but the Wilburs sustained additional uninsured losses. Cambridge Mutual brought a subrogation action against Crete for the amount paid to the Wilburs under the fire insurance policy; the Wilburs sought reimbursement from Crete for their uninsured losses.
In reviewing a motion to dismiss for failure to state a claim upon which relief may be granted, we assume the truth of all facts alleged by the plaintiffs and construe all reasonable inferences in the light most favorable to them. Graves v. Estabrook, 149 N.H. 202, 203 (2003). If the facts do not *675constitute a basis for legal relief, we will uphold the granting of the motion to dismiss. Id.
Crete contends that there is no basis for legal relief because, under the Sutton doctrine, a tenant is considered a coinsured of a landlord with respect to fire damage to leased residential premises. See Sutton v. Jondahl, 532 P.2d 478, 482 (Okla. Ct. App. 1975). An insurer, therefore, has no right of subrogation against a tenant whose negligence causes fire damage. Id. Likewise, a landlord may not hold a tenant liable for any uninsured losses as a result of fire damage where the landlord did not have adequate insurance. We find the reasoning of the Sutton court persuasive, and adopt an identical rule for residential leases in New Hampshire.
The majority of jurisdictions agree with the Oklahoma Court of Appeals’ reasoning in Sutton that “[b]asic equity and fundamental justice upon which the equitable doctrine of subrogation is established requires that when fire insurance is provided for a dwelling it protects the insurable interests of all joint owners including the possessory interests of a tenant absent an express agreement by the latter to the contrary.” Id.; see also, e.g., Lexington Ins. Co. v. Raboin, 712 A.2d 1001, 1015 n.17 (Del. Super. Ct. 1998).
A reasonable residential tenant expects that the landlord has fire insurance to protect the rental property, just as a reasonable insurance company expects to provide coverage for fire damage that may result from the actions of a tenant of the insured. See Sutton, 532 P.2d at 482. The insurance company reasonably expects to pay for negligently caused fires, and takes into account that the insured property will be rented to tenants, adjusting their rates accordingly. See Safeco Ins. Co. v. Capri, 705 P.2d 659, 661 (Nev. 1985).
Moreover, it is likely that the tenant pays a portion of the insurance policy’s premium through the rent. Sutton, 532 P.2d at 482. The premium is a business expense associated with rental properties and, therefore, taken into consideration when establishing the rent rate on the rental unit. Id.
Furthermore, if the Sutton doctrine is rejected, tenants are placed in the untenable position of having to carry fire insurance for the entire building in which they rent, regardless of the extent of their possessory interest or lack of knowledge necessary to procure adequate coverage. See DiLullo v. Joseph, 792 A.2d 819, 822-23 (Conn. 2002). In such a situation, there would be multiple insurance policies covering the same building, resulting in economic waste. See id. at 823; Peterson v. Silva, 704 N.E.2d 1163, 1166 (Mass. 1999).
*676It is permissible under the Sutton doctrine, however, for a landlord and tenant to enter into an express agreement or lease provision that would place responsibility for fire damage upon the tenant. For example, a rental agreement could require the tenant to carry fire insurance to insure against the tenant’s own negligence, or specify that the landlord’s insurance would not cover the tenant in the event of a fire caused by the tenant’s negligence. Sutton, 532 P.2d at 482. Absent an express agreement in a residential lease that places liability upon the tenant for the tenant’s own negligence in causing a fire, however, the tenant is considered a coinsured and is not obligated to subrogate the landlord’s insurer. Id.
Thus, under the Sutton doctrine, Crete, a residential tenant, is a coinsured of the Wilburs under the Cambridge Mutual insurance policy, unless there was an express agreement or provision in the lease to the contrary. The plaintiffs argue that paragraph seven of the lease allocates liability to Crete for any fire damage caused by his negligence. Paragraph seven reads:
Tenant must take good care of the Leased Premises and all equipment and fixtures contained therein. Tenant is responsible and liable for all repairs, replacements, and damages caused by or required as a result of any acts or neglect of the Tenant, Occupants, invitees or guests. If Tenant fails to make a needed repair or replacement, Landlord may do it and add the expenses to the rent.
This paragraph does not explicitly state that the tenant is not considered a coinsured of the landlord under any fire insurance policy obtained by the landlord. Nor does it explicitly require the tenant to obtain his or her own fire insurance for the leased premises. Paragraph seven of the lease does not address the specific issue of the tenant’s liability for fire damages caused by the tenant’s negligence; thus, it is not an express agreement or provision that negates the presumption that the tenant is a coinsured of the landlord for purposes of any fire insurance coverage on the leased premises. See Peterson, 704 N.E.2d at 1165; Cascade Trailer Court v. Beeson, 749 P.2d 761, 766 (Wash. Ct. App. 1988), review denied, 110 Wash. 2d 1030 (1988) (provision in lease preventing negligent destruction of premises does not indicate express intention to limit benefit of fire insurance to landlord). Crete is a coinsured of the Wilburs; therefore, Cambridge Mutual cannot subrogate against Crete for any damages paid as a result of his negligently causing a fire. Accordingly, Cambridge Mutual’s writ was properly dismissed.
*677The Wilburs argue that even if Cambridge Mutual’s subrogation action is dismissed, their action as to their uninsured losses must stand. The trial court found that the public policy concerns underlying the Sutton doctrine require the dismissal of the Wilburs’ writ as well. We agree.
If landlords were able to recover for uninsured losses caused by a tenant’s negligently caused fire damage, there would be little incentive for landlords to procure adequate fire insurance. Tenants would be placed in the situation that the Sutton doctrine seeks to avoid, where they must contemplate purchasing additional fire insurance for the leased premises as well as any personal property of the landlord on the premises. Tenants in this vulnerable position may lack sufficient knowledge about a landlord’s uninsured real or personal property to protect themselves. This would lead to the economic waste and duplicative insurance policies the Sutton doctrine aims to prevent. See DiLullo, 792 A.2d at 823.
Finally, a tenant has a reasonable expectation that the landlord has procured adequate fire insurance not only for the real property, but also for any other landlord-owned property on the premises. See Peterson, 704 N.E.2d at 1166. Thus, we hold that the Wilburs’ writ was properly dismissed in accordance with the Sutton doctrine.
The Wilburs next contend that the trial court’s order violates their right to equal protection under the New Hampshire Constitution. See N.H. CONST, pt. I, arts. 2,12. They argue that by extending the Sutton doctrine to bar actions by landlords against tenants for uninsured losses, the trial court impermissibly created different opportunities for recovery among tort victims.
In order to implicate the provisions of the Equal Protection Clause, the requisite “State action” must be demonstrated. In re Dumaine, 135 N.H. 103, 109 (1991). Absent some action that may fairly be attributed to the State, there can be no constitutional violation. Id. The Wilburs argue that the trial court’s application of the Sutton doctrine is sufficient “State action” to implicate the Equal Protection Clause.
The Sutton doctrine sets forth a judicial interpretation of a private agreement (a lease) made between landlords and tenants. Absent an express provision allocating liability to the tenant for fire damages to the leased premises, the tenant is a coinsured of the landlord under the landlord’s insurance coverage for the property. By applying the Sutton doctrine to the facts of this case, the trial court did not render a decision that results in the State categorically denying a class of people certain benefits. See Shelley v. Kraemer, 334 U.S. 1 (1948). Landlords are not precluded from recovering damages for uninsured losses from negligent *678tenants. Landlords and tenants may negotiate a lease that contains an express agreement or provision allocating that liability to the tenant.
In Dumaine, we failed to find the necessary State action in the trial court’s interpretation of trust documents. Dumaine, 135 N.H. at 109. Similarly, we do not find State action in the trial court’s interpretation of the lease. To hold otherwise would subject all judicial interpretations of private agreements to equal protection challenges. Id. at 110. There is no “State action” involved in this dispute; thus, the Wilburs’ equal protection claim is unfounded.
Finally we address the plaintiffs’ argument that the trial court erroneously denied their motion to amend the writ to add a count alleging that Crete intentionally set the fire. The court held that because it had dismissed the writ, the writ could not be amended.
The decision to grant or deny a motion to amend rests in the sound discretion of the trial court, and we will not overturn it unless it is an unsustainable exercise of discretion. Keshishian v. CMC Radiologists, 142 N.H. 168, 176 (1997); see also State v. Lambert, 147 N.H. 295, 296 (2001) (explaining unsustainable exercise of discretion standard).
A dismissal of a writ for failure to state a cause of action is a dismissal on the merits. ERG, Inc. v. Barnes, 137 N.H. 186, 189 (1993). This rule is consistent with modern rules of pleading and particularly with our liberal doctrine of amendment. Id. To assure that the opportunity for amendment has practical meaning, however, the plaintiff must be given leave to amend the writ to correct perceived deficiencies before an adverse judgment has preclusive effect. Id. Therefore, the trial court must allow the plaintiff opportunity to amend the writ before dismissing for failure to state a claim, allowing the plaintiff two chances to state a case before precluding the plaintiff from burdening the courts and opposing parties with further attempts. Id.
We have upheld trial courts’ decisions to deny leave to amend where the plaintiffs have failed to amend after being given ample opportunity, or did not file the motion to amend until after the order of dismissal had become a final judgment. See Warren v. Town of East Kingston, 145 N.H. 249, 253 (2000); Arsenault v. Scanlon, 139 N.H. 592, 593-94 (1995).
The plaintiffs in this case filed their motion to amend the writ on November 22, 2002, prior to the trial court’s March 17, 2003 dismissal order. The trial court denied the plaintiffs’ motion to amend the writ while simultaneously dismissing the writ. This was an unsustainable exercise of *679discretion, because ERG requires that a trial court allow plaintiffs at least one opportunity to amend a writ prior to dismissal for failure to state a claim. See ERG, 137 N.H. at 189. Thus, the trial court erred by denying the motion solely because it had dismissed the writ; the court should have considered the motion to amend on its merits.
The trial court correctly dismissed the writ as drafted, but erred when it denied the plaintiffs’ motion to amend. Accordingly, we vacate the order denying the motion to amend and remand to the trial court for proceedings consistent with this opinion.
Affirmed in part,; vacated in part; and, remanded.
Nadeau and Duggan, JJ., concurred.