Make use of SplFileObject class instead of function calls

I prefer it as it throws Exceptions and of course it is more OOP