WeixiangYan/CodeTransOcean huggingface dataset:
Task: Loops_Nested








VB: Public Sub LoopsNested()
    Dim a(1 To 10, 1 To 10) As Integer
    Randomize
    For i = 1 To 10
        For j = 1 To 10
            a(i, j) = Int(20 * Rnd) + 1
        Next j
    Next i
    For i = 1 To 10
        For j = 1 To 10
            If a(i, j) <> 20 Then
                Debug.Print a(i, j),
            Else
                i = 10 
                Exit For 
            End If
        Next j
        Debug.Print
    Next i
End Sub



Fortran:       PROGRAM LOOPNESTED
        INTEGER A, I, J, RNDINT

C       Build a two-dimensional twenty-by-twenty array.
        DIMENSION A(20,20)

C       It doesn't matter what number you put here.
        CALL SDRAND(123)

C       Fill the array with random numbers.
        DO 20 I = 1, 20
          DO 10 J = 1, 20
            A(I, J) = RNDINT(1, 20)
   10     CONTINUE
   20   CONTINUE

C       Print the numbers.
        DO 40 I = 1, 20
          DO 30 J = 1, 20
            WRITE (*,5000) I, J, A(I, J)

C           If this number is twenty, break out of both loops.
            IF (A(I, J) .EQ. 20) GOTO 50
   30     CONTINUE
   40   CONTINUE

C       If we had gone to 40, the DO loop would have continued. You can
C       label STOP instead of adding another CONTINUE, but it is good
C       form to only label CONTINUE statements as much as possible.
   50   CONTINUE
        STOP

C       Print the value so that it looks like one of those C arrays that
C       makes everybody so comfortable.
 5000   FORMAT('A[', I2, '][', I2, '] is ', I2)
      END

C FORTRAN 77 does not come with a random number generator, but it is
C easy enough to type "fortran 77 random number generator" into your
C preferred search engine and to copy and paste what you find. 
C The following code is a slightly-modified version of:
C
C     http://www.tat.physik.uni-tuebingen.de/
C         ~kley/lehre/ftn77/tutorial/subprograms.html
      SUBROUTINE SDRAND (IRSEED)
        COMMON  /SEED/ UTSEED, IRFRST
        UTSEED = IRSEED
        IRFRST = 0
        RETURN
      END
      INTEGER FUNCTION RNDINT (IFROM, ITO)
        INTEGER IFROM, ITO
        PARAMETER (MPLIER=16807, MODLUS=2147483647,                     &
     &              MOBYMP=127773, MOMDMP=2836)
        COMMON  /SEED/ UTSEED, IRFRST
        INTEGER HVLUE, LVLUE, TESTV, NEXTN
        SAVE    NEXTN
        IF (IRFRST .EQ. 0) THEN
          NEXTN = UTSEED
          IRFRST = 1
        ENDIF
        HVLUE = NEXTN / MOBYMP
        LVLUE = MOD(NEXTN, MOBYMP)
        TESTV = MPLIER*LVLUE - MOMDMP*HVLUE
        IF (TESTV .GT. 0) THEN
          NEXTN = TESTV
        ELSE
          NEXTN = TESTV + MODLUS
        ENDIF
        IF (NEXTN .GE. 0) THEN
          RNDINT = MOD(MOD(NEXTN, MODLUS), ITO - IFROM + 1) + IFROM
        ELSE
          RNDINT = MOD(MOD(NEXTN, MODLUS), ITO - IFROM + 1) + ITO + 1
        ENDIF
        RETURN
      END
Task: Loops_Nested






PHP: <?php
for ($i = 0; $i < 10; $i++)
    for ($j = 0; $j < 10; $j++)
        $a[$i][$j] = rand(1, 20);

foreach ($a as $row) {
    foreach ($row as $element) {
        echo " $element";
        if ($element == 20)
            break 2; // 2 is the number of loops we want to break out of
    }
    echo "\n";
}
echo "\n";
?>





Fortran:       PROGRAM LOOPNESTED
        INTEGER A, I, J, RNDINT

C       Build a two-dimensional twenty-by-twenty array.
        DIMENSION A(20,20)

C       It doesn't matter what number you put here.
        CALL SDRAND(123)

C       Fill the array with random numbers.
        DO 20 I = 1, 20
          DO 10 J = 1, 20
            A(I, J) = RNDINT(1, 20)
   10     CONTINUE
   20   CONTINUE

C       Print the numbers.
        DO 40 I = 1, 20
          DO 30 J = 1, 20
            WRITE (*,5000) I, J, A(I, J)

C           If this number is twenty, break out of both loops.
            IF (A(I, J) .EQ. 20) GOTO 50
   30     CONTINUE
   40   CONTINUE

C       If we had gone to 40, the DO loop would have continued. You can
C       label STOP instead of adding another CONTINUE, but it is good
C       form to only label CONTINUE statements as much as possible.
   50   CONTINUE
        STOP

C       Print the value so that it looks like one of those C arrays that
C       makes everybody so comfortable.
 5000   FORMAT('A[', I2, '][', I2, '] is ', I2)
      END

C FORTRAN 77 does not come with a random number generator, but it is
C easy enough to type "fortran 77 random number generator" into your
C preferred search engine and to copy and paste what you find. 
C The following code is a slightly-modified version of:
C
C     http://www.tat.physik.uni-tuebingen.de/
C         ~kley/lehre/ftn77/tutorial/subprograms.html
      SUBROUTINE SDRAND (IRSEED)
        COMMON  /SEED/ UTSEED, IRFRST
        UTSEED = IRSEED
        IRFRST = 0
        RETURN
      END
      INTEGER FUNCTION RNDINT (IFROM, ITO)
        INTEGER IFROM, ITO
        PARAMETER (MPLIER=16807, MODLUS=2147483647,                     &
     &              MOBYMP=127773, MOMDMP=2836)
        COMMON  /SEED/ UTSEED, IRFRST
        INTEGER HVLUE, LVLUE, TESTV, NEXTN
        SAVE    NEXTN
        IF (IRFRST .EQ. 0) THEN
          NEXTN = UTSEED
          IRFRST = 1
        ENDIF
        HVLUE = NEXTN / MOBYMP
        LVLUE = MOD(NEXTN, MOBYMP)
        TESTV = MPLIER*LVLUE - MOMDMP*HVLUE
        IF (TESTV .GT. 0) THEN
          NEXTN = TESTV
        ELSE
          NEXTN = TESTV + MODLUS
        ENDIF
        IF (NEXTN .GE. 0) THEN
          RNDINT = MOD(MOD(NEXTN, MODLUS), ITO - IFROM + 1) + IFROM
        ELSE
          RNDINT = MOD(MOD(NEXTN, MODLUS), ITO - IFROM + 1) + ITO + 1
        ENDIF
        RETURN
      END
Task: Loops_Nested

C: #include <stdlib.h>
#include <time.h>
#include <stdio.h>

int main() {
    int a[10][10], i, j;

    srand(time(NULL));
    for (i = 0; i < 10; i++)
        for (j = 0; j < 10; j++)
            a[i][j] = rand() % 20 + 1;

    for (i = 0; i < 10; i++) {
        for (j = 0; j < 10; j++) {
            printf(" %d", a[i][j]);
            if (a[i][j] == 20)
                goto Done;
        }
        printf("\n");
    }
Done:
    printf("\n");
    return 0;
}









COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Nested-Loop.

       DATA DIVISION.
       LOCAL-STORAGE SECTION.
       78  Table-Size VALUE 10.
       01  Table-Area.
           03  Table-Row OCCURS Table-Size TIMES
                   INDEXED BY Row-Index.
               05  Table-Element PIC 99 OCCURS Table-Size TIMES
                   INDEXED BY Col-Index.

       01  Current-Time PIC 9(8).
       PROCEDURE DIVISION.
*          
           ACCEPT Current-Time FROM TIME
           MOVE FUNCTION RANDOM(Current-Time) TO Current-Time

*          
*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                       UNTIL Table-Size < Row-Index
                   AFTER Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
               COMPUTE Table-Element (Row-Index, Col-Index) =
                   FUNCTION MOD((FUNCTION RANDOM * 1000), 20) + 1
           END-PERFORM

*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                   UNTIL Table-Size < Row-Index
               PERFORM VARYING Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
                   IF Table-Element (Row-Index, Col-Index) = 20
                       EXIT PERFORM
                   ELSE
                       DISPLAY Table-Element (Row-Index, Col-Index)
                   END-IF
               END-PERFORM
           END-PERFORM

           GOBACK
           .
Task: Loops_Nested



C#: using System;

class Program {
    static void Main(string[] args) {
        int[,] a = new int[10, 10];
        Random r = new Random();

        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                a[i, j] = r.Next(0, 21) + 1;
            }
        }
        
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                Console.Write(" {0}", a[i, j]);
                if (a[i, j] == 20) {
                    goto Done;
                }
            }
            Console.WriteLine();
        }
    Done:
        Console.WriteLine();
    }
}







COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Nested-Loop.

       DATA DIVISION.
       LOCAL-STORAGE SECTION.
       78  Table-Size VALUE 10.
       01  Table-Area.
           03  Table-Row OCCURS Table-Size TIMES
                   INDEXED BY Row-Index.
               05  Table-Element PIC 99 OCCURS Table-Size TIMES
                   INDEXED BY Col-Index.

       01  Current-Time PIC 9(8).
       PROCEDURE DIVISION.
*          
           ACCEPT Current-Time FROM TIME
           MOVE FUNCTION RANDOM(Current-Time) TO Current-Time

*          
*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                       UNTIL Table-Size < Row-Index
                   AFTER Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
               COMPUTE Table-Element (Row-Index, Col-Index) =
                   FUNCTION MOD((FUNCTION RANDOM * 1000), 20) + 1
           END-PERFORM

*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                   UNTIL Table-Size < Row-Index
               PERFORM VARYING Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
                   IF Table-Element (Row-Index, Col-Index) = 20
                       EXIT PERFORM
                   ELSE
                       DISPLAY Table-Element (Row-Index, Col-Index)
                   END-IF
               END-PERFORM
           END-PERFORM

           GOBACK
           .
Task: Loops_Nested


C++: #include<cstdlib>
#include<ctime>
#include<iostream>

using namespace std;
int main()
{
    int arr[10][10];
    srand(time(NULL));
    for(auto& row: arr)
        for(auto& col: row)
            col = rand() % 20 + 1;

    ([&](){
       for(auto& row : arr)
           for(auto& col: row)
           {
               cout << col << endl;
               if(col == 20)return;
           }
    })();
    return 0;
}








COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Nested-Loop.

       DATA DIVISION.
       LOCAL-STORAGE SECTION.
       78  Table-Size VALUE 10.
       01  Table-Area.
           03  Table-Row OCCURS Table-Size TIMES
                   INDEXED BY Row-Index.
               05  Table-Element PIC 99 OCCURS Table-Size TIMES
                   INDEXED BY Col-Index.

       01  Current-Time PIC 9(8).
       PROCEDURE DIVISION.
*          
           ACCEPT Current-Time FROM TIME
           MOVE FUNCTION RANDOM(Current-Time) TO Current-Time

*          
*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                       UNTIL Table-Size < Row-Index
                   AFTER Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
               COMPUTE Table-Element (Row-Index, Col-Index) =
                   FUNCTION MOD((FUNCTION RANDOM * 1000), 20) + 1
           END-PERFORM

*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                   UNTIL Table-Size < Row-Index
               PERFORM VARYING Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
                   IF Table-Element (Row-Index, Col-Index) = 20
                       EXIT PERFORM
                   ELSE
                       DISPLAY Table-Element (Row-Index, Col-Index)
                   END-IF
               END-PERFORM
           END-PERFORM

           GOBACK
           .
Task: Loops_Nested





Java: import java.util.Random;

public class NestedLoopTest {
    public static final Random gen = new Random();
    public static void main(String[] args) {
        int[][] a = new int[10][10];
        for (int i = 0; i < a.length; i++)
            for (int j = 0; j < a[i].length; j++)
                a[i][j] = gen.nextInt(20) + 1;

        Outer:for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a[i].length; j++) {
                System.out.print(" " + a[i][j]);
                if (a[i][j] == 20)
                    break Outer; 
            }
            System.out.println();
        }
        System.out.println();
    }
}





COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Nested-Loop.

       DATA DIVISION.
       LOCAL-STORAGE SECTION.
       78  Table-Size VALUE 10.
       01  Table-Area.
           03  Table-Row OCCURS Table-Size TIMES
                   INDEXED BY Row-Index.
               05  Table-Element PIC 99 OCCURS Table-Size TIMES
                   INDEXED BY Col-Index.

       01  Current-Time PIC 9(8).
       PROCEDURE DIVISION.
*          
           ACCEPT Current-Time FROM TIME
           MOVE FUNCTION RANDOM(Current-Time) TO Current-Time

*          
*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                       UNTIL Table-Size < Row-Index
                   AFTER Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
               COMPUTE Table-Element (Row-Index, Col-Index) =
                   FUNCTION MOD((FUNCTION RANDOM * 1000), 20) + 1
           END-PERFORM

*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                   UNTIL Table-Size < Row-Index
               PERFORM VARYING Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
                   IF Table-Element (Row-Index, Col-Index) = 20
                       EXIT PERFORM
                   ELSE
                       DISPLAY Table-Element (Row-Index, Col-Index)
                   END-IF
               END-PERFORM
           END-PERFORM

           GOBACK
           .
Task: Loops_Nested







Python: from random import randint

def do_scan(mat):
    for row in mat:
        for item in row:
            print item,
            if item == 20:
                print
                return
        print
    print

mat = [[randint(1, 20) for x in xrange(10)] for y in xrange(10)]
do_scan(mat)



COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Nested-Loop.

       DATA DIVISION.
       LOCAL-STORAGE SECTION.
       78  Table-Size VALUE 10.
       01  Table-Area.
           03  Table-Row OCCURS Table-Size TIMES
                   INDEXED BY Row-Index.
               05  Table-Element PIC 99 OCCURS Table-Size TIMES
                   INDEXED BY Col-Index.

       01  Current-Time PIC 9(8).
       PROCEDURE DIVISION.
*          
           ACCEPT Current-Time FROM TIME
           MOVE FUNCTION RANDOM(Current-Time) TO Current-Time

*          
*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                       UNTIL Table-Size < Row-Index
                   AFTER Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
               COMPUTE Table-Element (Row-Index, Col-Index) =
                   FUNCTION MOD((FUNCTION RANDOM * 1000), 20) + 1
           END-PERFORM

*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                   UNTIL Table-Size < Row-Index
               PERFORM VARYING Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
                   IF Table-Element (Row-Index, Col-Index) = 20
                       EXIT PERFORM
                   ELSE
                       DISPLAY Table-Element (Row-Index, Col-Index)
                   END-IF
               END-PERFORM
           END-PERFORM

           GOBACK
           .
Task: Loops_Nested








VB: Public Sub LoopsNested()
    Dim a(1 To 10, 1 To 10) As Integer
    Randomize
    For i = 1 To 10
        For j = 1 To 10
            a(i, j) = Int(20 * Rnd) + 1
        Next j
    Next i
    For i = 1 To 10
        For j = 1 To 10
            If a(i, j) <> 20 Then
                Debug.Print a(i, j),
            Else
                i = 10 
                Exit For 
            End If
        Next j
        Debug.Print
    Next i
End Sub


COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Nested-Loop.

       DATA DIVISION.
       LOCAL-STORAGE SECTION.
       78  Table-Size VALUE 10.
       01  Table-Area.
           03  Table-Row OCCURS Table-Size TIMES
                   INDEXED BY Row-Index.
               05  Table-Element PIC 99 OCCURS Table-Size TIMES
                   INDEXED BY Col-Index.

       01  Current-Time PIC 9(8).
       PROCEDURE DIVISION.
*          
           ACCEPT Current-Time FROM TIME
           MOVE FUNCTION RANDOM(Current-Time) TO Current-Time

*          
*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                       UNTIL Table-Size < Row-Index
                   AFTER Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
               COMPUTE Table-Element (Row-Index, Col-Index) =
                   FUNCTION MOD((FUNCTION RANDOM * 1000), 20) + 1
           END-PERFORM

*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                   UNTIL Table-Size < Row-Index
               PERFORM VARYING Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
                   IF Table-Element (Row-Index, Col-Index) = 20
                       EXIT PERFORM
                   ELSE
                       DISPLAY Table-Element (Row-Index, Col-Index)
                   END-IF
               END-PERFORM
           END-PERFORM

           GOBACK
           .
Task: Loops_Nested




Go: package main

import (
    "fmt"
    "math/rand"
    "time"
)

func main() {
    rand.Seed(time.Now().UnixNano())

    values := make([][]int, 10)
    for i := range values {
        values[i] = make([]int, 10)
        for j := range values[i] {
            values[i][j] = rand.Intn(20) + 1
        }
    }

outerLoop:
    for i, row := range values {
        fmt.Printf("%3d)", i)
        for _, value := range row {
            fmt.Printf(" %3d", value)
            if value == 20 {
                break outerLoop
            }
        }
        fmt.Printf("\n")
    }
    fmt.Printf("\n")
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Nested-Loop.

       DATA DIVISION.
       LOCAL-STORAGE SECTION.
       78  Table-Size VALUE 10.
       01  Table-Area.
           03  Table-Row OCCURS Table-Size TIMES
                   INDEXED BY Row-Index.
               05  Table-Element PIC 99 OCCURS Table-Size TIMES
                   INDEXED BY Col-Index.

       01  Current-Time PIC 9(8).
       PROCEDURE DIVISION.
*          
           ACCEPT Current-Time FROM TIME
           MOVE FUNCTION RANDOM(Current-Time) TO Current-Time

*          
*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                       UNTIL Table-Size < Row-Index
                   AFTER Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
               COMPUTE Table-Element (Row-Index, Col-Index) =
                   FUNCTION MOD((FUNCTION RANDOM * 1000), 20) + 1
           END-PERFORM

*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                   UNTIL Table-Size < Row-Index
               PERFORM VARYING Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
                   IF Table-Element (Row-Index, Col-Index) = 20
                       EXIT PERFORM
                   ELSE
                       DISPLAY Table-Element (Row-Index, Col-Index)
                   END-IF
               END-PERFORM
           END-PERFORM

           GOBACK
           .
Task: Loops_Nested






PHP: <?php
for ($i = 0; $i < 10; $i++)
    for ($j = 0; $j < 10; $j++)
        $a[$i][$j] = rand(1, 20);

foreach ($a as $row) {
    foreach ($row as $element) {
        echo " $element";
        if ($element == 20)
            break 2; // 2 is the number of loops we want to break out of
    }
    echo "\n";
}
echo "\n";
?>
Task: Loops_Nested






PHP: <?php
for ($i = 0; $i < 10; $i++)
    for ($j = 0; $j < 10; $j++)
        $a[$i][$j] = rand(1, 20);

foreach ($a as $row) {
    foreach ($row as $element) {
        echo " $element";
        if ($element == 20)
            break 2; // 2 is the number of loops we want to break out of
    }
    echo "\n";
}
echo "\n";
?>






Ada: with Ada.Text_IO;  use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;

procedure Test_Loop_Nested is
   type Value_Type is range 1..20;
   package Random_Values is new Ada.Numerics.Discrete_Random (Value_Type);
   use Random_Values;
   Dice : Generator;
   A : array (1..10, 1..10) of Value_Type :=
          (others => (others => Random (Dice)));
begin

Outer :
   for I in A'Range (1) loop
      for J in A'Range (2) loop
         Put (Value_Type'Image (A (I, J)));
         exit Outer when A (I, J) = 20;
      end loop;
      New_Line;
   end loop Outer;
end Test_Loop_Nested;
Task: Loops_Nested






PHP: <?php
for ($i = 0; $i < 10; $i++)
    for ($j = 0; $j < 10; $j++)
        $a[$i][$j] = rand(1, 20);

foreach ($a as $row) {
    foreach ($row as $element) {
        echo " $element";
        if ($element == 20)
            break 2; // 2 is the number of loops we want to break out of
    }
    echo "\n";
}
echo "\n";
?>




COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Nested-Loop.

       DATA DIVISION.
       LOCAL-STORAGE SECTION.
       78  Table-Size VALUE 10.
       01  Table-Area.
           03  Table-Row OCCURS Table-Size TIMES
                   INDEXED BY Row-Index.
               05  Table-Element PIC 99 OCCURS Table-Size TIMES
                   INDEXED BY Col-Index.

       01  Current-Time PIC 9(8).
       PROCEDURE DIVISION.
*          
           ACCEPT Current-Time FROM TIME
           MOVE FUNCTION RANDOM(Current-Time) TO Current-Time

*          
*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                       UNTIL Table-Size < Row-Index
                   AFTER Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
               COMPUTE Table-Element (Row-Index, Col-Index) =
                   FUNCTION MOD((FUNCTION RANDOM * 1000), 20) + 1
           END-PERFORM

*          
*          
           PERFORM VARYING Row-Index FROM 1 BY 1
                   UNTIL Table-Size < Row-Index
               PERFORM VARYING Col-Index FROM 1 BY 1
                       UNTIL Table-Size < Col-Index
                   IF Table-Element (Row-Index, Col-Index) = 20
                       EXIT PERFORM
                   ELSE
                       DISPLAY Table-Element (Row-Index, Col-Index)
                   END-IF
               END-PERFORM
           END-PERFORM

           GOBACK
           .
Task: File input_output



C#: using System;
using System.IO;

namespace FileIO
{
  class Program
  {
    static void Main()
    {
      String s = scope .();
      File.ReadAllText("input.txt", s);
      File.WriteAllText("output.txt", s);
    }
  }
}









Ada: with Ada.Text_IO; use Ada.Text_IO;
 
procedure Read_And_Write_File_Line_By_Line is
   Input, Output : File_Type;
begin
   Open (File => Input,
         Mode => In_File,
         Name => "input.txt");
   Create (File => Output,
           Mode => Out_File,
           Name => "output.txt");
   loop
      declare
         Line : String := Get_Line (Input);
      begin
         
         Put_Line (Output, Line);
      end;
   end loop;
   Close (Input);
   Close (Output);
exception
   when End_Error =>
      if Is_Open(Input) then 
         Close (Input);
      end if;
      if Is_Open(Output) then 
         Close (Output);
      end if;
end Read_And_Write_File_Line_By_Line;