Fix an issue with wasteful allocation in replaceLine().