Implementation of an efficient and error-tolerant readfile