Changed replace to regular expression rather than having duplicate copies of the file.