Why research before writing
Writing first and thinking about SEO afterward usually means rework. Finding out what term people actually search for, before you start writing, helps you structure the article around demand that already exists.
Start from the reader's question
Instead of thinking of an isolated word, think of the question someone is trying to answer. 'How to remove duplicate lines' tends to reflect real search behavior better than just 'duplicate lines'.
Watch the search suggestions
The autocomplete suggestions any search engine shows as you type are a free source of real variations people search for around a topic.