Cleanup main php file

And adapted for STDIN line at once instead per char