            segment .data
    infp    dq      0
    argv    dq      0
    read_mode:
            db      "r",0

            segment .bss
    data    resb    160
    data_size equ   $-data

            segment .text
            global  main
            extern  fopen, fgets, fputs, fclose, stdout

    main:
            push    rbp
            mov     rbp, rsp
    	frame	2, 0, 3
    	sub	rsp, frame_size

    ;       Step past argv[0]
            add     rdx, 8
            mov     [argv], rdx

    ;       Process each file
    .more_files:
            mov     r8, [argv]
            mov     rcx, [r8]     ; get the next filename into rcx
            cmp     rcx, 0
            je      .done
            add     r8, 8         ; advance argv
            mov     [argv], r8
            lea     rdx, [read_mode]
            call    fopen
            cmp     rax, 0
            je      .more_files
            mov     [infp], rax    ; save the file pointer
    .more_lines:
            lea     rcx, [data]    ; first parameter of fgets
            mov     rdx, data_size ; second parameter to fgets
            mov     r8, [infp]     ; third parameter
            call    fgets
            cmp     rax, 0
            jne     .put
            mov     rcx, [infp]
            call    fclose         ; close the file
            jmp     .more_files
    .put    lea     rcx, [data]    ; first parameter of fputs
            mov     rdx, [stdout]  ; second parameter
            call    fputs
            jmp     .more_lines
    .done   xor     eax, eax
            leave
            ret