add feature of read multiple files instead of one file a time,
add error checking code at some critical places