changed from reading each line to reading entire file using read()