Fixed bug whereby output of sed wasn't being saved to right file.