added some extra check for picking up the right file or creating a new one..