There are many suggested ways to avoid loneliness such as reading, writing about something or someone you like or love,
listening to the music or songs, etc. But the one that I find the most effective is, the word of God. The word of God is God
according to (John 1:1), and the word of God is God speaking. So, whenever I feel lonely, I just turn to the word of God.