you need to initialize the "i" value in copy function, if not it may take some unexpected value and getline() output is returning number of characters not EOF so you need to change while loop condition also.
Changes:
Original : while ((len = getline(line, MAX_LINE)) != EOF)
changed : while ((len = getline(line, MAX_LINE)) != 0)
void copy(char to[], char from[], int position)
{
// int i; Original
int i =0;
while ((to[position] = from[i]) != '\0')
{
i++;
position++;
}
}
if you initialize i=0 in copy function, you will get output.