diff --git a/workflow/scripts/motif_search.py b/workflow/scripts/motif_search.py
index 5cf27851e02e964f894fc304a29cfb1cfcef20cd..6de1b63c16b63b80f9e2443b51880450d805b1ee 100644
--- a/workflow/scripts/motif_search.py
+++ b/workflow/scripts/motif_search.py
@@ -57,8 +57,8 @@ def motif_search(filename, genome, experiment):
 
     # Sort Bed file by
     out, err = run_pipe([
-        'sort -k %dgr,%dgr %s' % (5, 5, filename),
-        sorted_fn)
+        'sort -k %dgr,%dgr %s' % (5, 5, filename)],
+        outfile=sorted_fn)
 
     # Get fasta file
     out, err = utils.run_pipe([