I'm not quite sure what you're after.
What language are you talking about?
"Get the output line by line"? What do you mean here?
OnlineGDB shows you the standard output of the program you run, so all you need to do is print things to the standard output line by line, meaning adding a new line when required.
For instance, in C/C++, you can use the newline character ('\n') to start a new line, just like in the example below.
#include <stdio.h>
int main()
{
printf("This goes to the first line.");
printf(" And so does this.");
printf("\nBut now, a new line is started and a new line character is added after the sentence.\n");
printf("So anything printed next, like this line, starts the line.\n");
return 0;
}If this is not what you're after, please, add more details.