My bash script is the following:
#!/bin/bash
if [ ! -f "$1" ]; then
  exit
fi
while read line;do
  str1="[GAC]*T"
  num=$"(echo $line | tr -d -c 'T' | wc -m)"
  for((i=0;i<$num;i++))do
    echo $line | sed "s/$str1/&\n/" | head -n1 -q
    str1="${str1}[GAC]*T"
  done
  str1="[GAC]*T"
done < "$1
While it works normally as it should (take the filename input and print it line by line until the letter T and next letter T and so on) it prints to the terminal.
Input:
GATTT
ATCGT
Output:
GAT
GATT
GATTT
AT
ATCGT
When I'm using the script with | tee outputfile the outputfile is correct but when using the script with > outputfile the terminal hangs / is stuck and does not finish.  Moreover it works with bash -x scriptname inputfile > outputfile but is stuck with bash scriptname inputfile > outputfile.