Completely overhauled the BuildFile Function