In Back to the future II, Marty burns the almanac in the bucket and Doc's DeLorean was struck by lightning, causing doc to travel to 1885 accidentally. Then Marty receives a letter from Doc which was written in 1885, saying that the time machine is at so and so place and do not come to 1885. Then Marty runs to Doc present in 1955, who has just sent 'other' Marty to 1985. The Marty says that, he's back from the future.
My question here is that, Doc goes to 1885 and he dies at the hands of Biff's Great grandfather. Then according to the timeline ripples, Doc will never be present in 1955. Thus all the events involving Doc after his death should have been altered. Just the time machine would be there at that place.
How did Marty meet Doc then (in 1955 for the second time)? It would be like a time loop that time machine was not created later (1985), it has been present before (1885) only and it makes the plot wrong.
Am I missing something here?