Does a writer have any rights to a work that has been completely rewritten by another writer? The rewriter used the original work as a blueprint, but ended up changing most of the details and developing the work significantly. Not a single line was untouched from the original work and though the general story of the rewritten work bears some similarities to the original, they mostly bare little resemblance. There is no written agreement, and it was initially intended that the original writer would be the sole writer and the rewriter would simply do a quick pass and make a few small changes. But, the writer decided to stop working as writer when he/she passed the work to the rewriter, making no effort or requests to write more.
If you are talking about legal copyright rights, then it would depend on the extent of the revisions. If, as you say, "not a single line was untouched", then I think the rewriter would own all rights. But if a lot of the original text is still there, then you have a joint work and you share ownership.
New writers routinely are confused about copyright. Copyright protects the actual words (or sounds or pictures) used to express an idea. It does not protect ideas. Writers are always saying, "Hey, I really loved Harry Potter and I want to write my own story about a boy with magic powers who goes to a wizard school. Do I have to get permission to use those ideas?" Answer: No. Copyright does not protect general ideas like "a story about wizards". It protects specific words.
So: If the original text said, for example, "To be, or not to be, that is the question", and you rewrote that to, "Existence, or non-existence, that's the point under debate", then even though the idea is the same, you have not borrowed any actual words (besides trivial ones like "or" and "the"), and so legally the sentence is 100% yours. If you dropped pages worth of material and substituted entirely different pages, that would make your case even more solid. On the other hand if you edited it to, "To be, or not to be, that's the point under debate", and if that's the case throughout the story -- a sentence here, a paragraph there, half a sentence over there -- than you'd be on shaky ground. If the other person sued for copyright infringement, a court would have to compare the two texts and make a subjective judgement.
Morally, if you borrowed heavily from the other person (or he borrowed from you, I'm not sure which player you are in this game), then I think you owe him something. It's pretty common to include credits in a creative work like, "based on a short story by ..." or "based on characters created by ...".
If there's cash involved, I'd see if I could come to an agreement with the other person, preferably in writing, and so prevent problems before they happen. Say, Hey, I think the final story is 80% mine and 20% yours, so how about we split any profits 80/20? Or whatever details.
I see two related issues here:
The script could be consider a derivative work since the second writer started with the the first writers script. If the second script is changed substantially it could be considered a new work; but if enough of the original story remains it could still be considered a derivative work.
With screenplays, however, the first writer will usually either get a story by, a based on a story by or an original story by credit, and at minimum a shared story credit. This is especially true when the second writer is hired to do the rewrite. In fact the WGA garuntees that for screenplays the original writer (a team is consider one writer) will get at minimum a shared story by credit.
If the second writer doesn't change enough, the first writer may get a shared writing credit. N.b. writing teams are separated with an '&' writers who worked separately on the same script are separated by an 'and' in the writing credit.
Copyright doesn't protect the idea, just the expression of the idea. Copyright attaches as soon as it is affixed to a medium, paper, electronic, or otherwise. No formal/written agreement needs to be made for this to occur. So without an agreement that the first writer abandoned their interest in the work, or ceded interest to the second it is possible that the first writer could claim the work as derivative of their own.