>> by that logic, you should never donate books to a library, since it is effectively costing the author sales.
Precisely. Should authors and publishers be paid by everyone that wants to read their work, or should the books be available freely to all that want them? (And yes, they would get paid for the number of books the library owns, but the system is set up to minimize that amount and it should certainly be less than the number of people reading them.)
What is the moral difference between pirating a book and paying no money to the author, or borrowing a copy that had been donated to a library and paying no money to the author? The borrowed copy prevents another patron from borrowing at the same time, but this feels more like a physical limitation (and legal loophole) than a morally relevent distinction.
People try to place value on making sure that authors get paid, and on making books freely available to all (that live near a library?), while neglecting that these are mostly incompatible with each other.
Oh, and the "I later bought my own copies" argument is also commonly used in favor of piracy.
It's reasons like this that I don't claim any strong opinions on these issues myself. Things are complicated. There are too many factors at play - especially when you toss in greedy corporations and all that - to make clear distinctions between right and wrong that hold up from all angles.