It your example, it looks like 'TTT' can start in different positions in different records. Is that the case, or does 'TTT' start in the same position in every record (which position?).
If 'TTT' can start in different positions in different records, then what do you mean by "TTT should appear at the end of the record" ( I assume you meant "record" here and not "file"). Do you mean 'TTT' should appear before a blank character, or something else? Please explain clearly what you mean by this. Does the first non-blank data byte (i.e. 1, 4, 5, 2, 4) start in the same position in every record? If so, which position?
Do you want the 'TTT' records at the end to appear in their original order or can they also appear in any order?