Fish do not get lonely unless they are a social fish. A social fish is one that is better off in a large shoal of usually 6-8 or more. Many fish, especially plecos, do not tolerate other fish especially their own kind. To that end, when you have that type of fish you need to overstock them to help prevent aggression. Most fish really don't "see" another fish as a friend in the human sense of friends. Some social fish are Guppies, endlers, tigerbarbs, bala sharks, Silver Dollars etc. It isn't so much a friendship as it is a feeling of safety in numbers. This is common in most shoaling fish. When a shoaling fish is raised solitary, they are often stressed from the lack of numbers and don't do well. Of course there are exceptions in everything and fish are no different.