new general function for reading files