Hi,

I am making an easy program that reads a text from a file and prints the content line by line indicating each number of line and printing >> at the end of each line.

This is the file: "prueba.txt" and its content:

Escribir un programa que abra un fichero llamado prueba.txt
previamente creado con el block de notas
y guardado en la misma carpeta que el programa
y que muestre el contenido del mismo por pantalla por lineas
y cada linea con su numero de linea seguido de >>

This is the code I have:

Code:
#include <stdio.h>
#include <stdlib.h>
#define SIZE_TEXTO 1000


int main()
{
    FILE *file;
    char texto[SIZE_TEXTO];


    file=fopen("prueba.txt", "r");
    int linea=0;


    while (fgets(texto,sizeof(texto),file)!=NULL) {
        printf("%d %s>>", ++linea, texto);
    }
    puts("");
    fclose(file);
    return 0;
}
The program do exactly what I want except prints >> in the next line:

Output:

1 Escribir un programa que abra un fichero llamado prueba.txt
>>2 previamente creado con el block de notas
>>3 y guardado en la misma carpeta que el programa
>>4 y que muestre el contenido del mismo por pantalla por lineas
>>5 y cada linea con su numero de linea seguido de >>>>


Process returned 0 (0x0) execution time : -0.000 s
Press any key to continue.

I want this output if possible:

1 Escribir un programa que abra un fichero llamado prueba.txt>>
2 previamente creado con el block de notas>>
3 y guardado en la misma carpeta que el programa>>
4 y que muestre el contenido del mismo por pantalla por lineas>>
5 y cada linea con su numero de linea seguido de >>>>


Process returned 0 (0x0) execution time : -0.000 s
Press any key to continue.

How can I fix it?

Thank you in advance.