Made file-reading more general