Have you tried to run it?
I think it misses at least a \n after $longline
Of course I did! Works fine for me.