slightly safer way of reading files