redirect debug to cerr
mingw and native gcc has slight difference.
check back with mingw again.
trim() now trims line endings tabs etc. than mere whitespace
more test with stringstream