fixed the failure to write mulitple script tags in the same write

Looks like the tests pass and this has solved #31