When your paper is rejected completely, treat this as the most common outcome and do not despair! One rejection does not imply that it will be rejected elsewhere. Remember that what one reviewer sees as a major problem might be overlooked by another.
Go back to your journal shortlist, or maybe reconsider your audience or type of journal you submit to. See the Choose Wisely section for advice and tips on choosing the right journal for your paper.
If the paper is rejected by multiple journals, especially if they all point out the same fundamental flaw, then it may be necessary to consign the paper to the filing cabinet. Learn from that experience how to improve next time.