title: End of stream encountered before parsing was completed
body: <p>I'm trying to read multiple objects from a file with this code:</p>
  
  <pre><code>List&lt;Alarm&gt; list = new List&lt;Alarm&gt;();
  BinaryFormatter serializer = new BinaryFormatter();
  
  using (FileStream stream = File.OpenRead("//my File here"))
  {
      while (stream.Position &lt; stream.Length)
      {
          list.Add((Alarm)serializer.Deserialize(stream));
      }
  }
  </code></pre>
  
  <p>However, everytime I try to run this code, I get an error like "End of Stream encountered before parsing was completed". Note that there is a thread existing already which suggests setting the streams position to 0 after each iteration, but that won't work for me obviously, or I would land in an infinite loop.</p>
  
  <p>What am I doing wrong here? The code itself works if I leave out the while loop, but obviously in a file with multiple objects I don't just want to get a single one out of my file, but rather all of them.</p>
  
  <p>Any advice?</p>
  
  <p>Edit: On demand:</p>
  
  <p>Serialization.</p>
  
  <pre><code>//Fetches Data from my GUI, creates a valid Alarm object
  Alarm alarm = new Alarm(this.noticeBox.Text, date.Year, date.Month, date.Day, (int)this.hourPicker.Value, (int)this.minutePicker.Value);
  
  var serializer = new BinaryFormatter();
  
  using (FileStream stream = "//file"))
  {
          serializer.Serialize(stream, alarm);
  }
  </code></pre>