While 문 사용 해서 텍스트 파일을 한줄씩 읽고 출력하기 



# 텍스트 파일 한줄씩 읽고 출력하기
# use while

# 파일을 읽기 모드로 오픈한다.
objFile = open("./sample_03_data.txt", 'r')

# 라인번호 저장 변수 초기값 설정
line_num = 1

# 라인을 읽어서 저장
line = objFile.readline()
while line:

    # 라인번호, 라인 읽은 데이타 출력
    print('%d %s' %(line_num, line), end='')

    # 새로운 라인 읽기
    line = objFile.readline()

    # 라인번호 증가시키기
    line_num += 1

# 파일 닫기
objFile.close()