'L{KnownHostsFile.save} will not overwrite existing entries in its save
path, even if they were only added after the L{KnownHostsFile} instance
was initialized.'

def test_savingsPreservesExisting(self):

    path = self.pathWithContent(sampleHashedLine)
    knownHosts = KnownHostsFile.fromPath(path)
    with path.open('a') as hostsFileObj:
        hostsFileObj.write(otherSamplePlaintextLine)
    key = Key.fromString(thirdSampleKey)
    knownHosts.addHostKey('brandnew.example.com', key)
    knownHosts.save()
    knownHosts = KnownHostsFile.fromPath(path)
    self.assertEqual([True, True, True], [knownHosts.hasHostKey('www.twistedmatrix.com', Key.fromString(sampleKey)), knownHosts.hasHostKey('divmod.com', Key.fromString(otherSampleKey)), knownHosts.hasHostKey('brandnew.example.com', key)])
