Make use of SplFileObject class instead of function calls