Algorithm to read, stock and print the next line of a string or of a file (using file decriptor)