fixed an error in greping and printing the respective sequencs to a file