#!/bin/sh
#
# This is a script to read a text file
#  and display the data.
# 
# The input file is formatted as:
#  state, capital
#
# The output is formatted as:
#   capital state
#

FILE='capitals'

exec 3< $FILE  # open the file for READ '<'
IFS=,

while read STATE CAPITAL <&3   # read a line from file #3
do
    echo "$CAPITAL $STATE"
done

exec 3<&-    # close file #3


