It looks like you're getting confused about Javascript and PHP and where each gets executed. What will actually happen with your code is that those <script> tags will be added to your hit.txt file (assuming it's got the right permissions, which could be another issue which may be why the file isn't saved)
PHP is run on the server, and Javascript is run in your browser, but you're attempting to mix them here in a way that won't work. If you want to get the dimensions of the screen added to a text file, then you need to do that with some sort of post back from the browser to the server. This is usually done with a single pixel image request (that actually points to a PHP script) with some extra info tagged onto the end of it:
<script type="text/javascript">
w = window.innerWidth; // note these two variables won't work in all browsers
h = window.innerHeight; // note these two variables won't work in all browsers
imgObj = new Image();
imgObj.src = "http://yourdomain/hit_count.php?w=" + w + "&h=" + h;
</script>
As noted above, the way you're attempting to get the width and height isn't compatible with all browsers, you should flesh that part out a bit, as IE, Firefox, etc have subtle differences in the way they do things like this.