Added file recognition, addmitedly not an expert at C++, but it should work alright