Trouble getting string to print random line from text file
<p>I picked up this bit of code a while back as a way to select a random line from a text file and output the result.  Unfortunately, it only seems to output the first letter of the line that it selects and I can't figure out why its doing so or how to fix it.  Any help would be appreciated.</p>

<pre><code>#include "stdafx.h"
#include &lt;stdio.h&gt;
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
#include &lt;time.h&gt;
using namespace std;

#define MAX_STRING_SIZE 1000

string firstName()
{
    string firstName;
    char str[MAX_STRING_SIZE], pick[MAX_STRING_SIZE];
    FILE *fp;
    int readCount = 0;

    fp = fopen("firstnames.txt", "r");
    if (fp)
    {
        if (fgets(pick, MAX_STRING_SIZE, fp) != NULL)
        {
            readCount = 1;
            while (fgets (str, MAX_STRING_SIZE, fp) != NULL)
            {
                if ((rand() % ++readCount) == 0)
                {
                    strcpy(pick, str);
                }
            }
        }
    }
    fclose(fp);
    firstName = *pick;
    return firstName;
}

int main() 
{
    srand(time(NULL));

    int n = 1;
    while (n &lt; 10)
    {
        string fn = firstName();
        cout &lt;&lt; fn &lt;&lt; endl;
        ++n;
    }

    system("pause");
}
</code></pre>
