In bioinformatics, long character strings are often encoded in a format called FASTA.

A FASTA file can contain several strings, each identified by a name marked by a > (greater than) character at the beginning of the line.



Task

Write a program that reads a FASTA file such as:

>Rosetta_Example_1
THERECANBENOSPACE
>Rosetta_Example_2
THERECANBESEVERAL
LINESBUTTHEYALLMUST
BECONCATENATED


Output:
Rosetta_Example_1: THERECANBENOSPACE
Rosetta_Example_2: THERECANBESEVERALLINESBUTTHEYALLMUSTBECONCATENATED

Note that a high-quality implementation will not hold the entire file in memory at once; real FASTA files can be multiple gigabytes in size.




open 1, "input.fasta"
 
first = True
 
while not eof(1)
    ln = readline(1)
    if left(ln, 1) = ">"  then
        if not first then print
        print mid(ln, 2, length(ln)-2) & ": ";
        if first then first = False
    else
        if first then
            print "Error : File does not begin with '>'"
            exit while
        else
            if checkNoSpaces(ln) then
                print left(ln, length(ln)-2);
            else
                print "Error : Sequence contains space(s)"
                exit while
            end if
        end if
    end if
end while
close 1
end
 
function checkNoSpaces(s)
    for i = 1 to length(s) - 1
        if chr(mid(s,i,1)) = 32 or chr(mid(s,i,1)) = 9 then return False
    next i
    return True
end function