Assuming "return0" has a space between "return" and "0" (given the different colors of the two), this does compile with several warnings. It also does exactly what I expected it to do after I mentally stepped through your code. It generates a key pair named lastfirst and lastfirst.pub (assuming those files don't already exist, of course), reads in one word at a time from lastfirst.pub into the "content" array, and then overwrites the lastfirst.pub file with three lines of comments and the last word from the original lastfirst.pub file. In my case, at least, this last word is my username@hostname, which is the comment field from the public key. A public key has three fields: the key type (ssh-rsa), the base64-encoded key, and an optional comment field.
Are you trying to copy the entire line to the new lastfirst.pub file? Then you'll have to read and save all three fields before overwriting the original file. Your code currently reads all three fields but overwrites the previous field each time, so only the last field is really saved.