Get the nth line of a file using bash

You have a file.txt with the following content :

Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10

Write a program that print the 7th line of this file :

Line 7

Method 1 with loop

#!/bin/bash
IFS=$'\n'

a=0;
for i in $(cat file.txt)
do
   ((a++));
   if (($a==7)) ; then
     echo $i;
   fi 
done

Method 2 with the sed command (faster than method 1)

sed "7q;d" file.txt