used a do while loop to deal with files greater than buffer size.
fixed control flow.