Not able to get the exact URL of the file on server located in active wordpress theme

You can’t put a php var, for example $url, in a string in this manner:

file_get_contents( "http://example.com/wp-content/themes/themename/download/$url/count.txt" );

You can use get_template_directory_uri to return the url to the current theme directory. For example:

$url = get_template_directory_uri() . '/download/count.txt';
echo file_get_contents( $url ); 

error code: 523